# Main context (this is the global configuration) worker_processes 4; events { worker_connections 1024; } http { include mime.types; # Upstream block to define the Node.js backend servers # Servers name come from compose definition upstream swarm1_cluster { server swarm1w1.sselab.ddns.net; server swarm1w2.sselab.ddns.net; server swarm1w3.sselab.ddns.net; server swarm1w4.sselab.ddns.net; } #TODO manage certs # server { # listen 443 ssl; # Listen on port 443 for HTTPS # server_name localhost; # # SSL certificate settings # ssl_certificate /Users/nana/nginx-certs/nginx-selfsigned.crt; # ssl_certificate_key /Users/nana/nginx-certs/nginx-selfsigned.key; # # Proxying requests to Node.js cluster # location / { # proxy_pass http://nodejs_cluster; # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # } # } # Optional server block for HTTP to HTTPS redirection server { listen 80; # Listen on port 80 for HTTP server_name *.sw1.sselab.ddns.net; location / { # Redirect all HTTP traffic to HTTPS # TODO requires https # return 301 https://$host$request_uri; proxy_pass http://nodejs_cluster; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name *.sw1.hassallab.it; location / { # Redirect all HTTP traffic to HTTPS # TODO requires https # return 301 https://$host$request_uri; proxy_pass http://nodejs_cluster; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } #Default Catch-all serving server { listen 80 default_server; server_name _; root /var/www/default; location /{ try_files $uri /$uri /index.php; } } }