diff --git a/compose.staging.yaml b/compose.staging.yaml new file mode 100644 index 0000000..a81bdc3 --- /dev/null +++ b/compose.staging.yaml @@ -0,0 +1,52 @@ +version: '3.8' + +services: + web: + build: ./wedding_site + command: gunicorn wedding_site.wsgi:application --bind 0.0.0.0:8000 + volumes: + - ./wedding_site/:/usr/src/app/ + - static_volume:/staticfiles + - media_volume:/mediafiles + expose: + - 8000 + env_file: + - ./.env.staging + + nginx-proxy: + container_name: nginx-proxy + build: ./nginx + restart: always + ports: + - 443:443 + - 8080:80 + volumes: + - static_volume:/staticfiles + - media_volume:/mediafiles + - certs:/etc/nginx/certs + - html:/usr/share/nginx/html + - vhost:/etc/nginx/vhost.d + - /var/run/docker.sock:/tmp/docker/sock:ro + depends_on: + - web + + acme-companion: + image: nginxproxy/acme-companion + env_file: + - ./.env.staging.proxy-companion + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - certs:/etc/nginx/certs + - html:/usr/share/nginx/html + - vhost:/etc/nginx/vhost.d + - acme:/etc/acme.sh + depends_on: + - nginx-proxy + +volumes: + static_volume: + media_volume: + certs: + html: + vhost: + acme: \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile index bdde282..e2f0ed0 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,4 +1,3 @@ -FROM docker.io/nginx - -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d \ No newline at end of file +FROM docker.io/nginxproxy/nginx-proxy +COPY vhost.d/default /etc/nginx/vhost.d/default +COPY custom.conf /etc/nginx/conf.d/custom.conf \ No newline at end of file diff --git a/nginx/custom.conf b/nginx/custom.conf new file mode 100644 index 0000000..e9a5e8e --- /dev/null +++ b/nginx/custom.conf @@ -0,0 +1 @@ +client_max_body_size 100M; \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf deleted file mode 100644 index 831bbbe..0000000 --- a/nginx/nginx.conf +++ /dev/null @@ -1,25 +0,0 @@ -upstream wedding_site { - server web:8000; -} - -server { - - listen 80; - - location / { - proxy_pass http://wedding_site; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_redirect off; - client_max_body_size 100M; - } - - location /static/ { - alias /staticfiles/; - } - - location /media/ { - alias /mediafiles/; - } - -} \ No newline at end of file diff --git a/nginx/vhost.d/default b/nginx/vhost.d/default new file mode 100644 index 0000000..bd8fd4d --- /dev/null +++ b/nginx/vhost.d/default @@ -0,0 +1,9 @@ +location /static/ { + alias /staticfiles/; + add_header Access-Control-Allow-Origin *; +} + +location /media/ { + alias /mediafiles/; + add_header Access-Control-Allow-Origin *; +} \ No newline at end of file diff --git a/wedding_site/primary/static/primary/favicon.ico b/wedding_site/primary/static/primary/favicon.ico new file mode 100755 index 0000000..115ea84 Binary files /dev/null and b/wedding_site/primary/static/primary/favicon.ico differ diff --git a/wedding_site/wedding_site/settings.py b/wedding_site/wedding_site/settings.py index b9992ed..33eb86b 100644 --- a/wedding_site/wedding_site/settings.py +++ b/wedding_site/wedding_site/settings.py @@ -111,6 +111,9 @@ USE_I18N = True USE_TZ = True +SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") +CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(" ") + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/