0

I am using a simple "hello world" Express.JS (8080 port) application deployed in Ubuntu Server, with NGINX reverse proxy setup as below.

The application working well for http port but not for https port

  • nginx version: nginx/1.10.3 (Ubuntu)
  • OpenSSL 1.0.2g 1 Mar 2016

And my configuration file is like this:

server {
        listen 80;
        listen 443 default ssl;
        server_name localhost;

         ssl_certificate /root/mydir/ssl/certificate.crt;
         ssl_certificate_key /root/mydir/ssl/private.key;

    location / {
                proxy_pass http://localhost:8080;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }
}

The configuration is working fine for http connection for my domain testdomain.com, but completely failing for https://testdomain.com or https://www.testdomain.com

What went wrong with this configuration?

SSL certs are generated by sslforfree.com.

1 Answer 1

1
server {
  listen       80;
   server_name example.com;

   # force redirect http to https
   rewrite ^ https://$http_host$request_uri? permanent;    
}

server {
  listen 443;
   ssl on;
   ssl_certificate /root/mydir/ssl/certificate.crt;
   ssl_certificate_key /root/mydir/ssl/private.key;
   server_name example.com;

   proxy_pass         http://127.0.0.1:8000;
   proxy_set_header   Host $host;
   proxy_set_header   X-Real-IP $remote_addr;
   proxy_set_header   X-Forwarded-Proto https;
   ....
 }
Sign up to request clarification or add additional context in comments.

6 Comments

Hi still i am getting the error site cannot be reached, and now even http also not working plz help
To make http work remove # force redirect http to https rewrite ^ https://$http_host$request_uri? permanent; What the logs are saying?
nginx access.log is empty , it not moving :-(
thank you for helping me , my issue is resolved now, i didnt notice 443 port is close. now enabled its working fine.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.