diff --git a/infra/stage/docker-compose.stage.yaml b/infra/stage/docker-compose.stage.yaml index 96169a1..0d19d97 100644 --- a/infra/stage/docker-compose.stage.yaml +++ b/infra/stage/docker-compose.stage.yaml @@ -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: @@ -23,6 +25,7 @@ services: - static_volume:/app/static/ ports: - 8002:8000 + gateway: image: lscr.io/linuxserver/swag:latest container_name: swag @@ -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 diff --git a/infra/stage/nginx.conf b/infra/stage/nginx.conf index 964897f..46a79aa 100644 --- a/infra/stage/nginx.conf +++ b/infra/stage/nginx.conf @@ -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; -# } +} diff --git a/poetry.lock b/poetry.lock index 01f645e..6619018 100644 --- a/poetry.lock +++ b/poetry.lock @@ -108,13 +108,13 @@ redis = ["redis (>=2.10.5)"] [[package]] name = "certifi" -version = "2024.7.4" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, - {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, + {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, + {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, ] [[package]] @@ -648,13 +648,13 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "28.0.0" +version = "28.1.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-28.0.0-py3-none-any.whl", hash = "sha256:6a3a08be54c37e05f7943d7ba5211d252c1de737687a46ad6f29209d8d5db11f"}, - {file = "faker-28.0.0.tar.gz", hash = "sha256:0d3c0399204aaf8205cc1750db443474ca0436f177126b2c27b798e8336cc74f"}, + {file = "Faker-28.1.0-py3-none-any.whl", hash = "sha256:b17d69312ef6485a720e21bffa997668c88876a5298b278e903ba706243c9c6b"}, + {file = "faker-28.1.0.tar.gz", hash = "sha256:bc460a0e6020966410d0b276043879abca0fac51890f3324bc254bb0a383ee3a"}, ] [package.dependencies]