简体   繁体   中英

nginx reverse proxy to https?

This is my config:

server {
        listen 80;
        server_name prettylogs.com;
        return 301 https://$server_name$request_uri;
}

server {
        listen 443 ssl;

        server_name prettylogs.com;
        location / {
                proxy_pass  https://localhost:9200/;
        }
}

When I visit prettylogs.com, I do get redirected to https://prettylogs.com , however the request never reaches my node server from nginx. If I go to the port directly, the node server is running and displays.

Any ideas?

There might be problem with your nginx conf file.

proxy_set_header   Host             $proxy_host;

it should have

proxy_set_header   Host             $host;

try with this updated configuration, your problem will be resolved.

Turns out that both ssl_certificate and ssl_certificate_key were required to get this working for me. I didn't see this mentioned anywhere, so there might be some setting which negates this, but this fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM