Configure Nginx as reverse proxy with upstream SSL using server_namenginx redirect issue with upstream configurationNginx/Apache: set HSTS only if X-Forwarded-Proto is httpsOCSP validation - unable to get local issuer certificateWARNING: None of the ciphers specified are supported by the SSL enginenginx reverse proxy hide login query also on 301 redirect or full qualified urlECDHE Cipher not being displayednginx seems to be ignoring ssl_ciphers settingSSL_read() failed (SSL: error:140943F2:SSL routines:SSL3_READ_BYTES:sslv3 error in nginxDisabling weak protocols and ciphers in Centos with ApachePostfix 2.6.6 with TLS - unable to receive emails from GMail (and a couple of other MTAs) but others are OK, why?
Sort a section of a file
Why wear sunglasses in indoor velodromes?
Quotient of Three Dimensional Torus by Permutation on Coordinates
Driving a school bus in the USA
Combining two Lorentz boosts
Would a "ring language" be possible?
Why is Drogon so much better in battle than Rhaegal and Viserion?
Can an airline pilot be prosecuted for killing an unruly passenger who could not be physically restrained?
How can I monitor the bulk API limit?
Windows reverting changes made by Linux to FAT32 partion
Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?
Why is choosing a suitable thermodynamic potential important?
What would be the game balance implications for using the Gygax method for applying falling damage?
Can ThermodynamicData be used with NSolve?
Why is the S-duct intake on the Tu-154 uniquely oblong?
Does the US Supreme Court vote using secret ballots?
Working hours and productivity expectations for game artists and programmers
French equivalent of the German expression "flöten gehen"
What technology would Dwarves need to forge titanium?
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Does the talk count as invited if my PI invited me?
Bookshelves: the intruder
What do you call bracelets you wear around the legs?
How many Dothraki are left as of Game of Thrones S8E5?
Configure Nginx as reverse proxy with upstream SSL using server_name
nginx redirect issue with upstream configurationNginx/Apache: set HSTS only if X-Forwarded-Proto is httpsOCSP validation - unable to get local issuer certificateWARNING: None of the ciphers specified are supported by the SSL enginenginx reverse proxy hide login query also on 301 redirect or full qualified urlECDHE Cipher not being displayednginx seems to be ignoring ssl_ciphers settingSSL_read() failed (SSL: error:140943F2:SSL routines:SSL3_READ_BYTES:sslv3 error in nginxDisabling weak protocols and ciphers in Centos with ApachePostfix 2.6.6 with TLS - unable to receive emails from GMail (and a couple of other MTAs) but others are OK, why?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I facing trouble using Nginx reverse proxy.
I have a server on a private network that provide the following website:
- a.example.com : 10.32.58.01 (internal DNS resolution)
- b.other.com : 10.32.58.01 (internal DNS resolution)
I created a Nginx reverse proxy with give access to theses two websites. This reverse proxy have IP 52.00.00.01 (fake one).
Public DNS resolution is:
- a.example.com : 52.00.00.01
- b.other.com : 52.00.00.01
The Nginx server /etc/hosts file contains the following resolution:
- 10.32.58.01 a.example.com b.other.com
The issue is that my two domains have different SSL certificate AND I want my reverse proxy to verify the SSL certificate.
Here is my failing Nginx reverse proxy configuration:
server
listen 80;
server_name a.example.com;
server_name b.other.com;
return 301 https://$host$request_uri;
server
listen 443 ssl http2;
server_name a.example.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.example.com.crt;
ssl_certificate_key ssl/example.com.key;
location /
proxy_pass https://a.example.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.example.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
server
listen 443 ssl http2;
server_name b.other.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.other.com.crt;
ssl_certificate_key ssl/other.com.key;
location /
proxy_pass https://b.other.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.other.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
The issue I got is when I'm requesting my reverse proxy, it returns 502 and I got in logs
[error] 2956#2956: *228502 upstream SSL certificate verify error: (2:unable to get issuer certificate) while SSL handshaking to upstream, client: 52.74.0.0, server: a.example.com, request: "GET / HTTP/1.1", upstream: "https://10.32.58.01:443/", host: "a.example.com"
So for now I disabled the upstream SSL verification -_-'
Thank You !
** EDIT **
In order to be more precise about the context here is my nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events
worker_connections 1024;
http
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/cert/dhparam.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
And my conf.d/proxy.conf
# if we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto
default $http_x_forwarded_proto;
'' $scheme;
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port
default $http_x_forwarded_port;
'' $server_port;
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection
default upgrade;
'' close;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl
default off;
https on;
access_log off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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 $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
proxy_ssl_server_name on;
proxy_ssl_session_reuse on;
server
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log;
return 503;
client_max_body_size 0;
proxy_request_buffering off;
client_body_buffer_size 1M;
client_header_buffer_size 512K;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
nginx ssl reverse-proxy https proxypass
add a comment |
I facing trouble using Nginx reverse proxy.
I have a server on a private network that provide the following website:
- a.example.com : 10.32.58.01 (internal DNS resolution)
- b.other.com : 10.32.58.01 (internal DNS resolution)
I created a Nginx reverse proxy with give access to theses two websites. This reverse proxy have IP 52.00.00.01 (fake one).
Public DNS resolution is:
- a.example.com : 52.00.00.01
- b.other.com : 52.00.00.01
The Nginx server /etc/hosts file contains the following resolution:
- 10.32.58.01 a.example.com b.other.com
The issue is that my two domains have different SSL certificate AND I want my reverse proxy to verify the SSL certificate.
Here is my failing Nginx reverse proxy configuration:
server
listen 80;
server_name a.example.com;
server_name b.other.com;
return 301 https://$host$request_uri;
server
listen 443 ssl http2;
server_name a.example.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.example.com.crt;
ssl_certificate_key ssl/example.com.key;
location /
proxy_pass https://a.example.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.example.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
server
listen 443 ssl http2;
server_name b.other.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.other.com.crt;
ssl_certificate_key ssl/other.com.key;
location /
proxy_pass https://b.other.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.other.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
The issue I got is when I'm requesting my reverse proxy, it returns 502 and I got in logs
[error] 2956#2956: *228502 upstream SSL certificate verify error: (2:unable to get issuer certificate) while SSL handshaking to upstream, client: 52.74.0.0, server: a.example.com, request: "GET / HTTP/1.1", upstream: "https://10.32.58.01:443/", host: "a.example.com"
So for now I disabled the upstream SSL verification -_-'
Thank You !
** EDIT **
In order to be more precise about the context here is my nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events
worker_connections 1024;
http
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/cert/dhparam.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
And my conf.d/proxy.conf
# if we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto
default $http_x_forwarded_proto;
'' $scheme;
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port
default $http_x_forwarded_port;
'' $server_port;
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection
default upgrade;
'' close;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl
default off;
https on;
access_log off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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 $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
proxy_ssl_server_name on;
proxy_ssl_session_reuse on;
server
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log;
return 503;
client_max_body_size 0;
proxy_request_buffering off;
client_body_buffer_size 1M;
client_header_buffer_size 512K;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
nginx ssl reverse-proxy https proxypass
add a comment |
I facing trouble using Nginx reverse proxy.
I have a server on a private network that provide the following website:
- a.example.com : 10.32.58.01 (internal DNS resolution)
- b.other.com : 10.32.58.01 (internal DNS resolution)
I created a Nginx reverse proxy with give access to theses two websites. This reverse proxy have IP 52.00.00.01 (fake one).
Public DNS resolution is:
- a.example.com : 52.00.00.01
- b.other.com : 52.00.00.01
The Nginx server /etc/hosts file contains the following resolution:
- 10.32.58.01 a.example.com b.other.com
The issue is that my two domains have different SSL certificate AND I want my reverse proxy to verify the SSL certificate.
Here is my failing Nginx reverse proxy configuration:
server
listen 80;
server_name a.example.com;
server_name b.other.com;
return 301 https://$host$request_uri;
server
listen 443 ssl http2;
server_name a.example.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.example.com.crt;
ssl_certificate_key ssl/example.com.key;
location /
proxy_pass https://a.example.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.example.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
server
listen 443 ssl http2;
server_name b.other.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.other.com.crt;
ssl_certificate_key ssl/other.com.key;
location /
proxy_pass https://b.other.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.other.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
The issue I got is when I'm requesting my reverse proxy, it returns 502 and I got in logs
[error] 2956#2956: *228502 upstream SSL certificate verify error: (2:unable to get issuer certificate) while SSL handshaking to upstream, client: 52.74.0.0, server: a.example.com, request: "GET / HTTP/1.1", upstream: "https://10.32.58.01:443/", host: "a.example.com"
So for now I disabled the upstream SSL verification -_-'
Thank You !
** EDIT **
In order to be more precise about the context here is my nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events
worker_connections 1024;
http
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/cert/dhparam.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
And my conf.d/proxy.conf
# if we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto
default $http_x_forwarded_proto;
'' $scheme;
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port
default $http_x_forwarded_port;
'' $server_port;
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection
default upgrade;
'' close;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl
default off;
https on;
access_log off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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 $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
proxy_ssl_server_name on;
proxy_ssl_session_reuse on;
server
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log;
return 503;
client_max_body_size 0;
proxy_request_buffering off;
client_body_buffer_size 1M;
client_header_buffer_size 512K;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
nginx ssl reverse-proxy https proxypass
I facing trouble using Nginx reverse proxy.
I have a server on a private network that provide the following website:
- a.example.com : 10.32.58.01 (internal DNS resolution)
- b.other.com : 10.32.58.01 (internal DNS resolution)
I created a Nginx reverse proxy with give access to theses two websites. This reverse proxy have IP 52.00.00.01 (fake one).
Public DNS resolution is:
- a.example.com : 52.00.00.01
- b.other.com : 52.00.00.01
The Nginx server /etc/hosts file contains the following resolution:
- 10.32.58.01 a.example.com b.other.com
The issue is that my two domains have different SSL certificate AND I want my reverse proxy to verify the SSL certificate.
Here is my failing Nginx reverse proxy configuration:
server
listen 80;
server_name a.example.com;
server_name b.other.com;
return 301 https://$host$request_uri;
server
listen 443 ssl http2;
server_name a.example.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.example.com.crt;
ssl_certificate_key ssl/example.com.key;
location /
proxy_pass https://a.example.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.example.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
server
listen 443 ssl http2;
server_name b.other.com;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 180m;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:!DSS';
ssl_session_tickets off;
ssl_certificate ssl/chained.other.com.crt;
ssl_certificate_key ssl/other.com.key;
location /
proxy_pass https://b.other.com;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_ssl_ciphers HIGH:!aNULL:!MD5;
proxy_ssl_trusted_certificate /etc/nginx/ssl/ssl/chained.other.com.crt;
proxy_ssl_server_name on;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_session_reuse on;
The issue I got is when I'm requesting my reverse proxy, it returns 502 and I got in logs
[error] 2956#2956: *228502 upstream SSL certificate verify error: (2:unable to get issuer certificate) while SSL handshaking to upstream, client: 52.74.0.0, server: a.example.com, request: "GET / HTTP/1.1", upstream: "https://10.32.58.01:443/", host: "a.example.com"
So for now I disabled the upstream SSL verification -_-'
Thank You !
** EDIT **
In order to be more precise about the context here is my nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events
worker_connections 1024;
http
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/cert/dhparam.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
And my conf.d/proxy.conf
# if we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto
default $http_x_forwarded_proto;
'' $scheme;
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port
default $http_x_forwarded_port;
'' $server_port;
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection
default upgrade;
'' close;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl
default off;
https on;
access_log off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
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 $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
proxy_ssl_server_name on;
proxy_ssl_session_reuse on;
server
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log;
return 503;
client_max_body_size 0;
proxy_request_buffering off;
client_body_buffer_size 1M;
client_header_buffer_size 512K;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
nginx ssl reverse-proxy https proxypass
nginx ssl reverse-proxy https proxypass
edited Oct 16 '17 at 12:04
moroine bentefrit
asked Oct 16 '17 at 10:18
moroine bentefritmoroine bentefrit
826
826
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You have to use HTTP/1.1 for the backend connection. Nginx uses HTTP/1.0 per default.
location /
proxy_pass https://a.example.com;
proxy_http_version 1.1;
...
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
add a comment |
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f878657%2fconfigure-nginx-as-reverse-proxy-with-upstream-ssl-using-server-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have to use HTTP/1.1 for the backend connection. Nginx uses HTTP/1.0 per default.
location /
proxy_pass https://a.example.com;
proxy_http_version 1.1;
...
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
add a comment |
You have to use HTTP/1.1 for the backend connection. Nginx uses HTTP/1.0 per default.
location /
proxy_pass https://a.example.com;
proxy_http_version 1.1;
...
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
add a comment |
You have to use HTTP/1.1 for the backend connection. Nginx uses HTTP/1.0 per default.
location /
proxy_pass https://a.example.com;
proxy_http_version 1.1;
...
You have to use HTTP/1.1 for the backend connection. Nginx uses HTTP/1.0 per default.
location /
proxy_pass https://a.example.com;
proxy_http_version 1.1;
...
answered Oct 18 '17 at 9:36
Jens BradlerJens Bradler
3,84121313
3,84121313
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
add a comment |
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
Thanks, but it's already present in conf.d/proxy.conf file. And it's not working
– moroine bentefrit
Oct 18 '17 at 11:41
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
You are right, I haven't seen it. Based on the error message it could be an issue because your server does not have the issuer's certificates installed. Have you tried to curl or wget the backend server from your nginx host?
– Jens Bradler
Oct 18 '17 at 13:11
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
Yeah I did and curl works fine without any validity issue.
– moroine bentefrit
Oct 19 '17 at 9:19
add a comment |
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
add a comment |
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
add a comment |
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
Try adding this in your server config:
proxy_ssl_verify_depth 2;
This sets the verification depth in the proxied HTTPS server certificates chain.
source : nginx_http_proxy_module
edited May 7 at 4:48
answered May 6 at 7:13
Mohit MalviyaMohit Malviya
1285
1285
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
add a comment |
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
It would be useful to explain why you think this would solve the problem described.
– womble♦
May 6 at 22:35
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f878657%2fconfigure-nginx-as-reverse-proxy-with-upstream-ssl-using-server-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown