Giter VIP home page Giter VIP logo

Comments (2)

Sebastix avatar Sebastix commented on July 29, 2024

When I do that, I got a 502 error from nginx

*2665 connect() failed (111: Connection refused) while connecting to upstream, client: 92.70.xxx.xxx, server: books.sebastix.social, request: "GET /setup HTTP/1.1", upstream: "http://127.0.0.1:8001/setup"

from documentation.

cenobitz avatar cenobitz commented on July 29, 2024

docker-compose.yml

version: '3'

services:
  nginx:
    image: nginx:latest
    restart: unless-stopped
    ports:
       - "8001:8001"
    depends_on:
      - web
    networks:
      - main
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - static_volume:/app/static
      - media_volume:/app/images
  db:
    image: postgres:13
    env_file: .env
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - main
  web:
    build: .
    env_file: .env
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/app
      - static_volume:/app/static
      - media_volume:/app/images
    depends_on:
      - db
      - celery_worker
      - redis_activity
    networks:
      - main
    ports:
      - "8000"

in bookwyrm /nginx/default.conf

include /etc/nginx/conf.d/server_config;

upstream web {
    server web:8000;
}

in /etc/nginx/sites-enabled/book.yourdomain.com

server {
    if ($host = book.yourdomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name book.yourdomain.com;

    listen [::]:80;
    listen 80;
    add_header Strict-Transport-Security "max-age=31536000;includeSubDomains" always;
    location / { return 301 https://$host$request_uri; }


}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    # SSL code
    ssl_certificate /etc/letsencrypt/live/book.yourdomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/book.yourdomain.com/privkey.pem; # managed by Certbot

    server_name book.yourdomain.com;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    location / {
        proxy_pass http://localhost:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }

    location /images/ {
        proxy_pass http://localhost:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }

    location /static/ {
        proxy_pass http://localhost:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }

}

This is working for me

from documentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.