So, I have this server block that supposed to redirect anything from port 80 to https. but somehow it’s not doing that. and when I access my site just using http. the website does not respond at all. I have my firewalls open(NGINX FULL), and i’m at a loss what do to.

server {
    listen 80;
    server_name opencallcentre.com;
    rewrite ^/(.*) https://opencallcentre.com/$1 permanent;
}




server {
    listen 443 ssl;        


  #root /var/www/html;
  #index index.html index.htm index.nginx-debian.html;

  server_name opencallcentre.com www.opencallcentre.com;

    ssl on;

    ssl_certificate /home/open-call-centre/opencallcentre.com.chained.crt;
  ssl_certificate_key /home/open-call-centre/opencallcentre.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';


       location / {
#       try_files $uri $uri/ =404;

        proxy_pass http://localhost:3000;
        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;
    }

}

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @marketingScubaDiver,

It seems the server block for port 80 is not configured properly. Can you please try with the following to see if it would work for you

server {
    listen 80;
    listen [::]:80;
    server_name opencallcentre.com www.opencallcentre.com;
    return 301 https://www.opencallcentre.com$request_uri;
}

I’ll additionally, recommend checking out the following tutorial about Nginx server blocks, it’s a good read :

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Regards,
KDSys

by Justin Ellingwood
When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu...
Show answer This answer has been marked as resolved by marketingScubaDiver.
Submit an Answer