# Redirect all HTTP traffic to HTTPS server { listen 80 default_server; listen [::]:80 default_server; location / { return 301 https://$host$request_uri; } } # Default server server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; include snippets/ssl.conf; location / { return 404; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/ssl.conf; # Server Whitelist for SNI Header (Server Name Indication) server_name EXAMPLE.COM *.TESTSERVER.COM 10.0.0.100; root /var/www; index index.html index.php; # replace with the IP address of your resolver #resolver 127.0.0.1; resolver [2606:4700:4700::1111] 1.1.1.1 [2606:4700:4700::1001] 1.0.0.1; # redirect to custom 404 error page on 403 or 404 error_page 403 =404 /404.html; error_page 404 =404 /404.html; client_max_body_size 15M; client_body_buffer_size 128K; location / { autoindex off; try_files $uri $uri/ =404; } location ~ /\.ht { deny all; } location ^~ /data/ { autoindex on; auth_basic "Please enter your login information"; auth_basic_user_file /etc/nginx/.htpasswd; } # CGI location ^~ /cgi-bin/ { include fastcgi_params; fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # PHP location ~ \.php$ { include snippets/fastcgi-php.conf; include fastcgi_params; fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # NodeJS location ^~ /helloworld-nodejs { include snippets/webapp-proxy.conf; proxy_pass http://localhost:8001/; } # ASP.NET Core location ^~ /helloworld-aspnet { include snippets/webapp-proxy.conf; proxy_pass http://localhost:8002/; } }