From 4be5e93c9c5621550a5c50269d46ecc5a19e546a Mon Sep 17 00:00:00 2001 From: jmsgrogan Date: Sun, 18 Feb 2024 15:04:22 +0000 Subject: [PATCH] Start adding virtual sites with nginx. --- compose.staging.yaml | 52 ++++++++++++++++++ nginx/Dockerfile | 7 +-- nginx/custom.conf | 1 + nginx/nginx.conf | 25 --------- nginx/vhost.d/default | 9 +++ .../primary/static/primary/favicon.ico | Bin 0 -> 15406 bytes wedding_site/wedding_site/settings.py | 3 + 7 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 compose.staging.yaml create mode 100644 nginx/custom.conf delete mode 100644 nginx/nginx.conf create mode 100644 nginx/vhost.d/default create mode 100755 wedding_site/primary/static/primary/favicon.ico 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 0000000000000000000000000000000000000000..115ea84d02d174299ba286b23348448610b6c15b GIT binary patch literal 15406 zcmeHNX;f547JfN1zvhgJF^O43!3A-R%IIj+$l|UL5C!6bppN@^6mdboeL-Usq5@(7 zF$%=EByMp@%%(;rq9H?cR6>Fdf{F^VuXpZu@o^f`;Ay(qCSB)rzwUak>fX9_>%OY{ zeTwpe@+ZZ_MB%HMGW*Yp(oazoGqdvlmMs+}g6n$qdUoGJQ7*l#D3<&TH{llL^?cD< zn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+|&AO{4{m}#Z@U#82IMAQ3A4$F%F*oLYu6* zs9P0QjsrpVtvg8sJDy=IL@h<^V{X1P2>uQE!12Hf0&eod^{do+WM`=d7NF+S!C$Hi zUA6V8;z-aJ{?mZ2FAsOr<5^wi(!f?Pf32lLW%(qOp{o|B3RUH|oF#dx*JG-Ms* z!j>pcvNJjN??$ikJ6T;9`GxspF}^ZR+GcEbf{wr$`*{u%%oXb?{ziiIqd6`^>Z+|T z$i2$EFqC|bL36iwi#=U^r_*nY2g4_TQ^RM#MFUR`aVeScpzPcn!KVVEf(U;2tO2x%y&b9uA7+y2w%qsx*`UZmX%5zLM*zRc!jK) zcX0Q9syvT2_yF4l-lg_~IR!2SjzC7{Bf&fM)wR0zz}?h18GYukaOj}_vYl%vuOLtE z#c=&n=G_5{M?bHR>B?AJU+O*Cnw*zUW$s=mV`(83z6ifdPW??V^qVQS$!oiBo!B3` z00&HebYE--yv~Ao0d1JiiM<92_Ij4QcU8v^+^;I10QW4$_oeH}H>C}@2t(&P37*(t zT%U?KrS@USD{QH*fu#Q?Q?JQG1aG}^{hH`{gR_GFz&sIOReiv_ zM1e1jdk$AqZKKO|0COn8D}|1bjeQN`NibuyDDYeGEWyJBUJl>J{to+s2|k__!~9NQ z?AV7uuDTY$n?)=|`~vQe0?_lM$C1Tcfja=7$9&aPuXsp+}=LGm^ z3p?{~nyUWbYy8!=ol{f9u%UA^o3>M$EPsPJCz>1-%maMM#MV5w(eh_lH|9KCXl`Tb Q0=o-;#`tBlfF2h39}82@E&u=k literal 0 HcmV?d00001 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/