nginx配置文件 http 强跳转 https-

七彩网络

昔年博客
首页>> Linux >>nginx配置文件 http 强跳转 https

路径 /usr/local/nginx/conf/conf.d/test.jackcui.com.conf

server {
    listen 80;
    server_name  test.jackcui.com;
    rewrite ^(.*)$ https://${server_name}$1 permanent;
}
 
server {
 listen 443 ssl;
 server_name test.jackcui.com;
 access_log   /data2/log/nginx/test.jackcui.com_access.log;
 error_log   /data2/log/nginx/test.jackcui.com_error.log;
 
 ssl_certificate   cert/2351572__jackcui.com.pem;
 ssl_certificate_key  cert/2351572__jackcui.com.key;
 ssl_session_timeout 5m;
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 ssl_prefer_server_ciphers on;
 
location / {
    proxy_pass http://10.0.0.1:8080;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $remote_addr;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    client_max_body_size 1024M; # Set higher depending on your needs
}
 
}

路径 /usr/local/nginx/conf/nginx.conf

user  nginx;
worker_processes  2;
 
events {
    use epoll;
    worker_connections  102400;
}
 
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
    server {
        listen       80;
        server_name  default_server;
 
        location / {
            root   /data1/web/default;
            index  index.html index.htm;
        }
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
    }
    include conf.d/*.conf;
 
    # 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配置文件 http 强跳转 https
分享本文至:
点击评论 您阅读这篇文章共花了: 

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)