Nginx : SSL/TLS Setting


[1] . Configure Nginx. For example, enable SSL/TLS on default site.

 
[root@www ~]# vi /etc/nginx/conf.d/ssl.conf
# add to the end

# replace servername and path of certificates to your own one

server {
    listen       443 ssl http2 default_server;
    listen       [::]:443 ssl http2 default_server;
    server_name  www.srv.world;
    root         /usr/share/nginx/html;

    ssl_certificate "/etc/letsencrypt/live/www.srv.world/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/www.srv.world/privkey.pem";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers PROFILE=SYSTEM;
    ssl_prefer_server_ciphers on;

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

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

[root@www ~]# systemctl restart nginx


[2] . If you'd like to set HTTP connection to redirect to HTTPS (Always on SSL/TLS), configure like follows.

 
[root@www ~]# vi /etc/nginx/nginx.conf
# add into the section of listening 80 port

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        return       301 https://$host$request_uri;
        server_name  www.srv.world;
        root         /usr/share/nginx/html;

[root@www ~]# systemctl restart nginx


[3]. If Firewalld is running, allow HTTPS service. HTTPS uses [443/TCP].

 
[root@www ~]# firewall-cmd --add-service=https --permanent
 success
[root@www ~]# firewall-cmd --reload
 success

 
[4] .Verify to access to the test page from a client computer with a Web browser via HTTPS. If you set Always On SSL/TLS, access with HTTP to verify the connection is redirected to HTTPS normally, too.

 

 

 

Comments

Popular posts from this blog

Java : Variables Declaring

Install DNF in RHEL/CentOS 7

SQL Self JOIN