Skip to content

Commit

Permalink
Merge pull request #188 from Pet-projects-CodePET/fix/deploy
Browse files Browse the repository at this point in the history
fix: Поправил nginx, certbot
  • Loading branch information
Denis-Shtanskiy authored Apr 21, 2024
2 parents 0cc9b0d + 409a719 commit 6d3c728
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 46 deletions.
10 changes: 5 additions & 5 deletions infra/docker-compose-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '3.8'

volumes:
pg_data:
Expand Down Expand Up @@ -57,19 +57,19 @@ services:
- static_volume:/staticfiles/
- media_value:/mediafiles/
- certbot:/certbot/
- letsencrypt:/letsencrypt/
- letsencrypt:/etc/letsencrypt/
restart: unless-stopped
depends_on:
- backend
- frontend

certbot:
image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_certbot:latest
image: certbot/certbot
env_file: .env
volumes:
- certbot:/var/www/certbot/
- letsencrypt:/etc/letsencrypt/
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 30d & wait $${!}; done;'"
restart: unless-stopped
depends_on:
- backend
- frontend
- nginx
36 changes: 8 additions & 28 deletions infra/nginx/nginx_dev.conf
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
#server {
# listen 80;
# listen [::]:80;
# server_name 89.23.117.80;
# server_tokens off;
#
# root /staticfiles;
#
# location / {
# return 301 https://devcodepet.tw1.ru$request_uri;
#}

server {
listen 80;
listen [::]:80;
server_name devcodepet.tw1.ru;
server_tokens off;

root /staticfiles;

location /.well-known/acme-challenge/ {
root /certbot;
}

location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}
server {
listen 80;
listen [::]:80;
server_name 89.23.117.80 devcodepet.tw1.ru;
server_tokens off;

location / {
if ($scheme = http) {
return 301 https://$host$request_uri;
if ($http_x_forwarded_proto != 'https') {
return https://$host$request_uri;
}
}
}
Expand All @@ -42,7 +26,6 @@ server {
ssl_certificate /letsencrypt/live/devcodepet.tw1.ru/fullchain.pem;
ssl_certificate_key /letsencrypt/live/devcodepet.tw1.ru/privkey.pem;

root /staticfiles;

location /api/v1/ {
proxy_set_header Host $http_host;
Expand All @@ -53,12 +36,9 @@ server {
proxy_pass http://backend:8000/admin/;
}

location /.well-known/acme-challenge/ {
root /certbot;
}

location / {
try_files $uri $uri.html $uri/ =404;
try_files $uri $uri.html $uri/ =404;
}

error_page 404 /404.html;
Expand Down
22 changes: 9 additions & 13 deletions infra/nginx/nginx_qa.conf
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
server {
listen 80;
listen [::]:80;
server_name 89.23.117.168 testcodepet.tw1.ru;
server_tokens off;

root /staticfiles;

location /.well-known/acme-challenge/ {
root /certbot;
}

location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

server {
listen 80;
listen [::]:80;
server_name 89.23.117.168 testcodepet.tw1.ru;
server_tokens off;

location / {
return 301 https://$host$request_uri;
if ($http_x_forwarded_proto != 'https') {
return https://$host$request_uri;
}
}
}

Expand All @@ -28,8 +26,6 @@ server {
ssl_certificate /letsencrypt/live/testcodepet.tw1.ru/fullchain.pem;
ssl_certificate_key /letsencrypt/live/testcodepet.tw1.ru/privkey.pem;

root /staticfiles;

location /api/v1/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/api/v1/;
Expand Down
1 change: 1 addition & 0 deletions src/backend/config/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"http://localhost:3000",
]


LOGGING["loggers"].pop("django.db.backends", None)
LOGGING["loggers"]["django"]["level"] = "WARNING"

Expand Down

0 comments on commit 6d3c728

Please sign in to comment.