Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

Explore the world of seamless email management with Zimbra Mail on Linux! Our blog delves into a step-by-step guide on harnessing the potential of Linux commands, providing easy-to-follow how-tos, and unlocking the magic of Bash scripting. Simplify your email administration journey and enhance your skills with our insightful tips and tricks.

Nginx redirect all http to https

In this tutorial, How to use nginx redirect all http to https. All traffic http redirect to https for your website.
How to do it.....
For example, nginx.conf file for your website
    server {
            listen 80;
            listen [::]:80;
            if ($host = www.huuphan.com) {
               return 301 https://$host$request_uri;
           }

            if ($host = huuphan.com) {
              return 301 https://$host$request_uri;
            }
            server_name www.huuphan.com huuphan.com;
            return 444;
            #return 301 https://$server_name$request_uri;

    }

    server {
            listen 443 ssl http2;
            listen [::]:443 ssl http2;
            server_name www.huuphan.com huuphan.com;
            access_log off;
            error_log /path/to/logs/error.log;
            root /path/to/webroot;
            index index.php index.html index.htm;
            location / {
               try_files $uri $uri/ /index.php?$args;
               index index.html index.htm index.php;
           }
    }
 Note: Using $host instead of $server_name to according to block your server.


post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com

This Blog is protected by DMCA.com