Skip to content

Commit

Permalink
Реконфиг swag и nginx (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kudralexandr authored Aug 30, 2024
2 parents b246ccc + 23cb2d9 commit 06c784e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 79 deletions.
15 changes: 4 additions & 11 deletions infra/stage/docker-compose.stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ services:
- pg_data:/var/lib/postgresql/data
ports:
- 5432:5432

backend:
image: ghcr.io/studio-yandex-practicum/goodstart_telegram_bot:dev
container_name: backend
env_file: ../../.env
restart: always
depends_on:
Expand All @@ -23,6 +25,7 @@ services:
- static_volume:/app/static/
ports:
- 8002:8000

gateway:
image: lscr.io/linuxserver/swag:latest
container_name: swag
Expand All @@ -33,23 +36,13 @@ services:
- PGID=1002 # gid=1002(google-sudoers) на stage
- TZ=Europe/Moscow
- URL=jetrai.ru
- VALIDATION=http
- SUBDOMAINS=www,bot #optional
- CERTPROVIDER= #optional
- DNSPLUGIN=cloudflare #optional
- PROPAGATION= #optional
- EMAIL= #optional
- ONLY_SUBDOMAINS=false #optional
- EXTRA_DOMAINS= #optional
- STAGING=false #optional
volumes:
- /home/aptalca/appdata/swag:/config
- ./nginx.conf:/config/nginx/site-confs/default.conf:ro
- static_volume:/static/
depends_on:
- backend
ports:
#- 8001:80
#- 8001:443
- 443:443
- 80:80
restart: unless-stopped
128 changes: 66 additions & 62 deletions infra/stage/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,76 +1,80 @@
server {
listen 80;
index index.html;
server_tokens off;
client_max_body_size 10M;

location /static/material/ {
alias /static/material/;
}
location /static/admin/ {
alias /static/admin/;
}
location /admin {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend:8000/admin;
}
location /registration {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend:8000/registration;
}
location / {
alias /static/;
autoindex on;
proxy_set_header Host $host;
}
}
listen 443 ssl http2;
listen [::]:443 ssl http2;

keepalive_timeout 45;
reset_timedout_connection on;
client_body_timeout 35;
send_timeout 30;

sendfile on;
aio on;
tcp_nopush on;

# server {
open_file_cache max=100000 inactive=20s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

# listen 443 ssl http2;
# listen [::]:443 ssl http2;
gzip on;
gzip_disable "msie6";

# keepalive_timeout 45;
# reset_timedout_connection on;
# client_body_timeout 35;
# send_timeout 30;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 1100;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

# sendfile on;
# aio on;
# tcp_nopush on;
server_name jetrai.ru;

# open_file_cache max=100000 inactive=20s;
# open_file_cache_valid 45s;
# open_file_cache_min_uses 2;
# open_file_cache_errors on;
include /config/nginx/ssl.conf;

# gzip on;
# gzip_disable "msie6";
client_max_body_size 10M;

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_min_length 1100;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
location /admin {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend:8000/admin;
}
location /static/material/ {
alias /static/material/;
}
location /static/admin/ {
alias /static/admin/;
}
location /registration {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://backend:8000/registration;
}
location / {
alias /static/;
autoindex on;
proxy_set_header Host $host;
}

# server_name jetrai.ru;
# location / {
# include /config/nginx/proxy.conf;
# set $upstream_app backend;
# set $upstream_port 8000;
# set $upstream_proto http;
# proxy_pass $upstream_proto://$upstream_app:$upstream_port;
# }
}

# include /config/nginx/ssl.conf;

# client_max_body_size 10M;
server {
if ($host = jetrai.ru) {
return 301 https://$host$request_uri;
}

# location / {
# include /config/nginx/proxy.conf;
# set $upstream_app bot;
# set $upstream_port 8000;
# set $upstream_proto http;
# proxy_pass $upstream_proto://$upstream_app:$upstream_port;
# }
listen 80;
server_name jetrai.ru;
return 301 https://$host$request_uri;

# }
}
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 06c784e

Please sign in to comment.