User Tools

Site Tools


wiki:nginx_http_https_config

nginx http to https config

Non-http file config

server {
    server_name example.com;
    listen 80;
 
    return 301 https://$host$request_uri;

Example https config:

server {
    listen 443 default_server ssl;
    listen  [::]:443 default_server ssl ipv6only=on;
	# SSL encryption parameters
        ssl                     on;
        ssl_protocols           TLSv1.2;
        ssl_session_cache       shared:SSL:10m;
        ssl_session_timeout     10m;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256;
        ssl_certificate /etc/nginx/ssl/example.crt;
        ssl_certificate_key /etc/nginx/ssl/example.key;
 
    # proxied routes
    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_connect_timeout       120;
        proxy_send_timeout          120;
        proxy_read_timeout          120;
        send_timeout                120;
    }
 
    location /signalr {
	proxy_pass http://localhost:8080;
	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_connect_timeout       120;
        proxy_send_timeout          120;
        proxy_read_timeout          120;
        send_timeout                120;
    }
}

Tested on

See also

References

wiki/nginx_http_https_config.txt · Last modified: 2021/07/09 10:26 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki