Created
November 14, 2017 12:31
-
-
Save shijij/54c9b21f26c08a15a70c182f03cb15b4 to your computer and use it in GitHub Desktop.
Nginx ssl reverse proxy with SNI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name yourdomain | |
ssl_certificate /etc/ssl/localcerts/yourdomain.crt; | |
ssl_certificate_key /etc/ssl/localcerts/yourdomain.key; | |
ssl_ecdh_curve prime256v1; | |
ssl_session_cache builtin:1000 shared:SSL:10m; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers 'ECDHE+aECDSA+CHACHA20:ECDHE+aRSA+CHACHA20:ECDHE+aECDSA+AESGCM:ECDHE+aRSA+AESGCM:ECDHE+aECDSA+AES256+SHA384:ECDHE+aRSA+AES256+SHA384:ECDHE+aECDSA+AES256+SHA:ECDHE+aRSA+AES256+SHA'; | |
location / { | |
proxy_set_header 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; | |
# Fix the “It appears that your reverse proxy set up is broken" error. | |
proxy_pass https://1.2.3.4; | |
proxy_read_timeout 60; | |
proxy_ssl_name $host; | |
proxy_ssl_server_name on; | |
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
proxy_ssl_session_reuse off; | |
} | |
} |
Thank you, this worked for me.
All I had to do was add these 2 lines to my config
proxy_ssl_name $host;
proxy_ssl_server_name on;
I find it is ok to have a ;
after server_name
, contrary to what c-l-h states. Perhaps newer versions of nginx are more forgiving than the version they are running.
nginx version: nginx/1.15.8
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
does it works???
https://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_ssl_name
Syntax: proxy_ssl_name name;
Context: stream, server
in your example proxy_ssl_name
is used in location
thank you ,it works.
Excellent, worked as per your example. :-)
Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! - found it after hours of searching and trying to get nginx to reverse proxy to a IIS server that required SNI, interesting that the
server_name
directive doesnt require a;
in fact it breaks if you add it (i thought it was a typo in your file at first).I did have to add
ssl on;
just before thessl_certificate
line though otherwise nginx would try to use the client cert instead of the upsteam cert.Thanks again