nginx 配置 多域名 多ssl 安全加密 配置

介绍

这里的配置域名都被改成了 123   321  这样的 正常使用真实的域名地址 ok

nginx 配置 多域名 多ssl 安全加密 配置_第1张图片

nginx 配置 多域名 多ssl 安全加密 配置_第2张图片nginx 配置 多域名 多ssl 安全加密 配置_第3张图片

 

第一部分nginx 基础配置内容

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;



}

基础的就不介绍了

nginx 配置 多域名 多ssl 安全加密 配置_第4张图片

第二部分第一个域名配置和ssl

     #-----------------------------璇.汉瀹..-------------------------------

        server {
        listen       80;
        server_name  www.123.com;
                rewrite ^(.*)$ https://www.123.com;
        }
    server {
        listen       443;
        server_name  www.123.com;


        ssl                  on;
        ssl_certificate      /home/nginx/ssl/srdz/1_www.123.com_bundle.crt;
        ssl_certificate_key  /home/nginx/ssl/srdz/2_www.123.com.key;
        ssl_session_timeout  5m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;



        location / {
            root   /home/nginx/html/webapp;
            index  /srdz/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

nginx 配置 多域名 多ssl 安全加密 配置_第5张图片nginx 配置 多域名 多ssl 安全加密 配置_第6张图片

第三部分  多家一个 域名 和ssl

    #----------------------------涓.储浼..--------------------------------

     server {
        listen       80;
        server_name  www.321.com;
                rewrite ^(.*)$ https://321.com;
        }

        server {
        listen       443;
        server_name  www.321.com;

                ssl                  on;
        ssl_certificate      /home/nginx/ssl/zcqh/1_www.321.com_bundle.crt;
        ssl_certificate_key  /home/nginx/ssl/zcqh/2_www.321.com.key;
        ssl_session_timeout  5m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;


        location / {
            root   /home/nginx/html/webapp;
            index  /zcgsweb/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

nginx 配置 多域名 多ssl 安全加密 配置_第7张图片nginx 配置 多域名 多ssl 安全加密 配置_第8张图片

还能新加内容呢 普通的配置 

     server {
        listen       80;
        server_name  www.333.net.cn;

                location / {
            root   /home/nginx/html/webapp;
            index  /tenxun/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        }

nginx 配置 多域名 多ssl 安全加密 配置_第9张图片nginx 配置 多域名 多ssl 安全加密 配置_第10张图片

内部转发调整 80 转443

  server {
        listen       80;
        server_name  www.123.com;
                rewrite ^(.*)$ https://www.123.com;
        }

nginx 配置 多域名 多ssl 安全加密 配置_第11张图片nginx 配置 多域名 多ssl 安全加密 配置_第12张图片

 

完整版 代码配置


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;



        #-----------------------------璇.汉瀹..-------------------------------

        server {
        listen       80;
        server_name  www.123.com;
                rewrite ^(.*)$ https://www.123.com;
        }
    server {
        listen       443;
        server_name  www.123.com;


        ssl                  on;
        ssl_certificate      /home/nginx/ssl/srdz/1_www.123.com_bundle.crt;
        ssl_certificate_key  /home/nginx/ssl/srdz/2_www.123.com.key;
        ssl_session_timeout  5m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;



        location / {
            root   /home/nginx/html/webapp;
            index  /srdz/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

        #----------------------------涓.储浼..--------------------------------

     server {
        listen       80;
        server_name  www.321.com;
                rewrite ^(.*)$ https://321.com;
        }

        server {
        listen       443;
        server_name  www.321.com;

                ssl                  on;
        ssl_certificate      /home/nginx/ssl/zcqh/1_www.321.com_bundle.crt;
        ssl_certificate_key  /home/nginx/ssl/zcqh/2_www.321.com.key;
        ssl_session_timeout  5m;
        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;


        location / {
            root   /home/nginx/html/webapp;
            index  /zcgsweb/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
        #------------------------------------------------------------

        #----------------------------涓.储浼..--------------------------------

        server {
        listen       80;
        server_name  www.333.net.cn;

                location / {
            root   /home/nginx/html/webapp;
            index  /tenxun/index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        }


        #------------------------------------------------------------

        #server {
    #    listen       9999;
    #    server_name  localhost;
        #       
     #   location / {
     #       root   /home/nginx/html/webapp/s001;
     #       index  /index.html;
     #   }
     #   error_page   500 502 503 504  /50x.html;
     #   location = /50x.html {
     #       root   html;
     #   }
    #}


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

nginx 配置 多域名 多ssl 安全加密 配置_第13张图片nginx 配置 多域名 多ssl 安全加密 配置_第14张图片nginx 配置 多域名 多ssl 安全加密 配置_第15张图片

 

 

ok 持续更新 

 

 

 

 

你可能感兴趣的:(nginx)