1

I am using Nginx to point a subdomain to a different port that a node.js server is listening to.

It works fine for http, but now I need to switch over to https.

This is what I have right now in sites-available/default:

server {
    listen 80;
    listen 443;
    server_name sub.example.com;

    location / {
        proxy_pass http://example.com:2222;
    }
}

Now that I am switching my node server over to https do I need to change the proxy_pass to https://example.com:2222?

hal
  • 4,845
  • 7
  • 34
  • 57
  • possible duplicate of [nginx proxy pass Node, SSL?](http://stackoverflow.com/questions/10375659/nginx-proxy-pass-node-ssl) – Hugo Dozois Aug 19 '14 at 18:18

2 Answers2

1

Now that I am switching my node server over to https do I need to change the proxy_pass to https://example.com:2222?

Short answer is no. It doesn't need to be same protocol for proxy as for incoming request But you may require another directive

proxy_set_header X-Forwarded-Proto https; 
monkeyinsight
  • 4,719
  • 1
  • 20
  • 28
0

I found this in my searches.

Turns out it's best to handle the SSL certification with nginx and leave node running a http server.

Community
  • 1
  • 1
hal
  • 4,845
  • 7
  • 34
  • 57