1 year ago

#385544

test-img

Geobongpapa

NginX https error (500 Internal Server Error) on CentOS

I'm using 'Oracle Cloud'. I created a VM(Computer instance) on Oracle Cloud with CentOS 8. And I installed NginX, and it works well when I test it with 'http://mydeal.servername.com'. To make NginX service with HTTPS, I also installed certbot(Let's Encrypt) and created certificate, using the following command.

sudo certbot --standalone -d mydeal.servername.com certonly 

Result files were like below.

Cert : /etc/letsencrypt/live/mydeal.servername.com/fullchain.pem;  
Key : /etc/letsencrypt/live/mydeal.servername.com/privkey.pem;

I added http and https to firewall service list like below.

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

And I created test index.html like below.

sudo -i
mkdir /var/www
mkdir /var/www/mydeal
echo "MyDeal at Oracle Cloud" > /var/www/mydeal/index.html

And I created https settings, including http redirection, in /etc/nginx/conf.d/my.conf file.

server {  
    listen 80;  
    server_name my.servername.com;  
    location / {  
            root    /var/www/mydeal;  
            index   index.html;  
            try_files       $uri /index.html;  
    }  
    return          301     https://$host$request_uri;  
}  
server {  
    listen 443 ssl http2;  
    listen [::]:443 ssl http2;  
    server_name mydeal.servername.com;  
    ssl_certificate /etc/letsencrypt/live/mydeal.servername.com/fullchain.pem;  
    ssl_certificate_key /etc/letsencrypt/live/mydeal.servername.com/privkey.pem;  
    location / {  
            root    /var/www/mydeal;  
            index   index.html;  
            try_files       $uri    /index.html;  
    }  
}

Finally, when I start nginx server with the following command, it works well.

sudo -i
sudo nginx

But, when I start nginx server with the following command, it gives error "500 Internal Server Error" on the browser screen.

sudo systemctl enable nginx
sudo systemctl start nginx

I can not find any differences b/w 2 start procedures. How I can debug this problem?

nginx

https

centos

certbot

0 Answers

Your Answer

Accepted video resources