1

I'm trying to enforce the SSL protocol in a Jelastic Enviroment. My setup is:

  • one node, with a Nginx Load balancer (+ public ip + custom ssl certificate) and a NodeJS application server.

The SSL setup is working, but i want to enforce the use of HTTPS no HTTP (a redirect).

I've tried to modify the nginx.conf but no success.

Any ideas how should I do that?

1 Answer 1

2

Create the config file /etc/nginx/conf.d/nginx_force_https.conf and add the lines below:

server {
    listen 80;       
    server_name _;
    return 301 https://$host$request_uri;
}

It will redirect all configured sites to https.

If you want only exact site example.com:

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

Make sure that you have these includes enabled in /etc/nginx/nginx.conf

include /etc/nginx/nginx-jelastic.conf;

in /etc/nginx/nginx-jelastic.conf:

include /etc/nginx/conf.d/*.conf;

Check for errors in the configuration:

sudo service nginx configtest

Reload configuration (this would be enough to make changes "work"):

sudo service nginx reload

Check if all works as expected. Restart the whole webserver (if needed):

sudo service nginx restart

The detailed answer can be found in this post Force www. and https in nginx.conf (SSL)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.