# Multiple domain configuration with SSL and HTTP/3 support
# Main domain redirects (www to non-www)
server {
listen 80;
listen [::]:80;
listen 443 quic reuseport;
listen 443 ssl http2;
listen [::]:443 quic reuseport;
listen [::]:443 ssl http2;
http2 on;
http3 on; # Enable HTTP/3 if supported
{{ssl_certificate_key}}
{{ssl_certificate}}
# Add all www variants
server_name www.test.in www.test2.in www.test3.in;
# Redirect www to non-www
return 301 https://$host$request_uri;
}
# Main server block for multiple domains
server {
listen 80;
listen [::]:80;
listen 443 quic reuseport;
listen 443 ssl http2;
listen [::]:443 quic reuseport;
listen [::]:443 ssl http2;
http2 on;
http3 on;
{{ssl_certificate_key}}
{{ssl_certificate}}
# Add all your domains here
server_name test.in test2.in test3.in;
{{root}}
# Logging
{{nginx_access_log}}
{{nginx_error_log}}
# Force HTTPS
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
# .well-known location for SSL certification validation
location ~ /.well-known {
auth_basic off;
allow all;
}
{{settings}}
include /etc/nginx/global_settings;
# Varnish proxy configuration
location / {
{{varnish_proxy_pass}}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-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_hide_header X-Varnish;
proxy_redirect off;
# Proxy timeouts
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
# Proxy buffering
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
}
# Static files handling with browser caching
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
add_header alt-svc 'h3=":443"; ma=86400';
expires max;
access_log off;
try_files $uri $uri/ /index.php?$query_string;
}
}
# PHP-FPM Server block
server {
listen 8080;
listen [::]:8080;
# Add all your domains here
server_name test.in test2.in test3.in;
{{root}}
# Laravel specific
index index.php index.html;
try_files $uri $uri/ /index.php?$query_string;
# PHP-FPM Configuration
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
# PHP settings
fastcgi_param PHP_VALUE "{{php_settings}}";
# Extended timeouts for long-running scripts
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_connect_timeout 60;
# Buffers
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
}
# Static files handling
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
try_files $uri $uri/ /index.php?$query_string;
}
}