Saturday, July 6, 2019

nginx reverse proxy to non-standard ssl port

I am having a terrible time getting this to work, here's my config file. When I navigate to 'sub.domain.com' I'm redirected to an https version of the URL so I know nginx is receiving the request, but the reverse proxy isn't loading 10.3.2.200:8443. When I load "https://sub.domain.com", Chrome tells me "ERR_CONNECTION_CLOSED". I'm using snippets from other answers on StackExchage + other online tutorials but with no success.



As a peculiarity, if I run a test and change 443 to 20205 in the second server block, then the reverse proxy works with 'https://sub.domain.com:20205' and successfully forwards to 10.3.2.200:8443.



## running on 10.3.2.205
upstream destsrv {
server 10.3.2.200:8443;
}
server {

listen 80 http2;
listen [::]:80 http2;
server_name sub.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sub.domain.com;
ssl_certificate /etc/letsencrypt/certs/star_domain_com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/certs/star_domain_com/privkey.pem;
location / {
proxy_pass https://destsrv;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
}
}



This is a reverse proxy on a home server, I have ports 80 and 443 forwarded to my nginx server.



What's going on here?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...