## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # https://www.nginx.com/resources/wiki/start/ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ # https://wiki.debian.org/Nginx/DirectoryStructure # # In most cases, administrators will remove this file from sites-enabled/ and # leave it as reference inside of sites-available where it will continue to be # updated by the nginx packaging team. # # This file will automatically load configuration files provided by other # applications, such as Drupal or Wordpress. These applications will be made # available underneath a path with that package name, such as /drupal8. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## # Default server configuration server { listen 5.129.192.136:443 ssl http2 default_server; # если нужен IPv6, добавь: listen [::]:443 ssl http2; server_name myvpntest.online; root /var/www/html; index index.html; # --- SSL (self-signed) --- ssl_certificate /etc/letsencrypt/live/maxru.zpmu.xyz/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/maxru.zpmu.xyz/privkey.pem; # базовые SSL-параметры ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; # заголовки безопасности (по желанию) add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options DENY; # таймауты (разумные) keepalive_timeout 1h; client_header_timeout 1h; client_body_timeout 1h; # ------------- gRPC ------------- # gRPC: подход для /TestChatGRPC и /%2FTestChatGRPC/... location ~* ^/(?:%2FTestChatGRPC|TestChatGRPC)(?:/.*)?$ { # мягкая проверка content-type (поддерживает application/grpc, application/grpc+proto и др.) if ($content_type !~* "grpc") { return 404; } client_max_body_size 0; client_body_buffer_size 512k; grpc_set_header Host $host; grpc_set_header X-Real-IP $remote_addr; grpc_set_header TE "trailers"; grpc_read_timeout 1h; grpc_send_timeout 1h; grpc_pass grpc://127.0.0.1:8888; } # ------------- WebSocket ------------- location = /TestChatWS { proxy_pass http://127.0.0.1:8889; proxy_http_version 1.1; # корректная обработка Upgrade proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # низкая задержка proxy_buffering off; proxy_read_timeout 1h; proxy_send_timeout 1h; } # простая index-страница location / { try_files $uri $uri/ =404; } }