# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; index index.html index.htm; server { server_name www.test.com; return 301 $scheme://test.com$request_uri; } server { listen 80; server_name www.domain.domain.com *.domain.com; location = / { return 301 https://domain.domain.com/Songs/join; } } server { listen 80 default_server; listen [::]:80 default_server; server_name test.com; root /usr/share/nginx/html1/html; location /s/ { try_files $uri $uri.php /s/router.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index /s/index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Always serve index.html unless it is some social media site location / { if ($http_user_agent ~ SkypeUriPreview|WhatsApp|UCCAPI|facebookexternalhit|Facebot|Twitterbot|Pinterest|LinkedInBot) { proxy_pass $scheme://$server_addr:$server_port/s$uri; } try_files $uri /index.html; } # Do not cache sw.js, required for offline-first updates. location /sw.js { add_header Cache-Control "no-cache"; expires off; access_log off; } error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot if ($scheme != "https"){ return 301 https://$host$request_uri; } # managed by Certbot } }