listen 443 default_server; location / { set $redirect 0; if ($server_port != 443) { set $redirect 1; } if ($http_user_agent ~* "ELB-HealthChecker") { set $redirect 0; } if ($redirect = 1) { return 301 https://$host$request_uri; } proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Connection $connection_upgrade; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }