nginx配置--- 本网站使用配置,备份提供参考

https 一级域名跳转二级域名配置

server{
        listen 443;
        server_name geek45.com;
         ssl on;
        ssl_certificate         /******.pem;
        ssl_certificate_key     /******.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;
        root /www/static-web/;
        index geek45.html;
        error_page 500 502 503 504 404          /404.html;
        location = 404.html{
                index 404.html;
        }}

geek45.html 页面内容
<html>
        <meta http-equiv="refresh" content="0;url=https://www.geek45.com/">
</html>

后台二级域名https配置

server {
        listen 443;
        server_name config.geek45.com;
        ssl on;
        ssl_certificate         /*******.pem;
        ssl_certificate_key     /*******.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://blog/;

                proxy_set_header  Host  $host;
                proxy_set_header  X-Real-ip $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

博客主页面https配置

server {
        listen 443;
        server_name *.geek45.com;
        ssl on;
        ssl_certificate         /********.pem;
        ssl_certificate_key     /********.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; 
        #root html;
        #index index.html index.htm;
        location / {
                proxy_pass http://tale_blog/;
                proxy_set_header  Host  $host;
                proxy_set_header  X-Real-ip $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                
        }
}

一级域名和二级域名 全部跳转https访问

server {
        listen 80;
        server_name geek45.com;
        location / {
                proxy_pass https://www.geek45.com/;

                proxy_set_header  Host  $host;
                proxy_set_header  X-Real-ip $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

        }
}

server {
        listen 80;
        server_name www.geek45.com;
        location / {
                root /www/static-web/;
                index geek45.html;
        }
}

server {
        listen 80;
        server_name config.geek45.com;
        location / {
                root /www/static-web/;
                index config.html;
        }
}

服务器维护的时候,跳转对应的网站,避免出现网站空白期

server {
        listen 8080;
        server_name geek45.com;
        root /www/static-web/;
        index index.html;
}

禁止ip访问服务器

server {
        listen 80 default;
        server_name _ ;
        root /www/static-web/;
        index 500.html;
}

nginx日志配置,调试时使用

log_format  main  '$remote_addr - [$time_local] "$request" -  [$http_x_forwarded_for] - [$http_referer]'


access_log  logs/access.log  main;

注意

以上所有配置,均在http{ ... } 里面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

写代码的喵o

请作者吃包辣条可好

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值