listen 80 default_server;
and add listen 443 and certificate/key path. Following example is for Let's Encrypt installation.
listen 80;
listen 443 default ssl;
ssl_certificate /etc/letsencrypt/live/domainname/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/domanname/privkey.pem;
To force http to https, add following in the server block say just after above entries. Myserver.com is used as server_name in following example.
server_name myserver.com;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
Check syntax error in config file:
nginx -t
/etc/init.d/nginx reload|restart
No comments:
Post a Comment