侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

本站tp5,hyperf,beego线上项目的nginx配置清单完整版

技术  /  管理员 发布于 3年前   1150

本人三个线上项目,就是本博客导航栏的前面三个项目链接了

这里我本人记录一下,虽然有备份,但是记录之,有利于自己偶尔看看,

也希望帮助到有需要有兴趣的同学查阅


我这里其他环境啥的有不说了,自行查阅我之前的文章,或谷歌搜索吧 


我直接贴配置文件信息

一些敏感信息 比如ip 我就省略了


#ip转域名

server {
  listen 80 default_server;
  listen 443 ssl http2;
  server_name _;
    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.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
  rewrite ^(.*) https://www.zongscan.com/ permanent;
}


#tp5 就是本站了

server
    {
listen       80;
listen 443 ssl http2;
server_name  www.zongscan.com;
    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.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    #把http的域名请求转成https
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #只允许GET\POST方法访问,其他的method返回405
    if ($request_method !~ ^(GET|POST)$ ) {
    return 405;
    }
#禁止ip
deny 23.100.232.233;
deny 72.14.199.0/24;
deny 167.99.98.220;
deny 77.245.3.2;
deny 64.120.121.55;
deny 150.158.12.71;
if ($http_user_agent ~* "ApacheBench|WebBench|Wget|Curl|HttpClient|Go-http-client|python"){ return 403; }
if ($http_user_agent ~* "MegaIndex|GrapeshotCrawler|MJ12bot|BLEXBot|MauiBot|AhrefsBot|SemrushBot|Scrapy|YandexBot|DotBot"){return 444;}
        #全站防盗链
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                valid_referers none blocked *.zongscan.com zongscan.com;
                if ($invalid_referer){ return 403;}
        }
    index index.html index.htm index.php;
    root  /home/www/tp5blog;
    location / { 
   if (!-e $request_filename) {
      rewrite  ^(.*)$  /index.php?s=/$1  last;
      break;
    }
    }
        error_page   404 403   /404.html;
        include enable-php.conf;
        location /nginx_status
        {
            stub_status off;
            access_log   off;
        }
access_log  /home/wwwlogs/blogwww.log main_log;
}



导航栏第二个hyperf2.1

#-----------------s
upstream web {
    server ...:9501;
}
upstream websocket {
    server ...:9502;
}
server
{
    listen 80;
    listen 443 ssl http2;
    server_name blog.zongscan.com;
    
    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.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    
    #80重定向443
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
# 屏蔽单个ip访问
deny 23.100.232.233; 
deny 74.125.150.0/24;
if ($http_user_agent ~* "ApacheBench|WebBench|Wget|Curl|HttpClient|Go-http-client|python"){ return 403; }
if ($http_user_agent ~* "MegaIndex|GrapeshotCrawler|MJ12bot|BLEXBot|MauiBot|AhrefsBot|SemrushBot|Scrapy|YandexBot|DotBot"){return 444;}
    
      #指向文件
      location = /favicon.ico{ root /opt/bg;}
      location = /robots.txt{ root /opt/bg;}
      location = /ads.txt{ root /opt/bg;}
      location = /shenma-site-verification.txt{ root /opt/bg;}
      
    #WebSocket服务
    location /ws {
        # WebSocket Header
        proxy_http_version 1.1;
        proxy_set_header Upgrade websocket;
        proxy_set_header Connection "Upgrade";
        # 将客户端的 Host 和 IP 信息一并转发到对应节点  
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        # 客户端与服务端无交互 60s 后自动断开连接,请根据实际业务场景设置
        proxy_read_timeout 60s ;
        # 执行代理访问真实服务器
        proxy_pass http://websocket;
    }
     
    #web 
    location / {
        ##跨域
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
        add_header Access-Control-Allow-Headers 'uid,token,Keep-Alive,User-Agent,Cache-Control,Content-Type,Authorization';
        if ($request_method = 'OPTIONS') {
                        add_header 'Access-Control-Max-Age' 1728000;
                        add_header 'Content-Type' 'text/plain charset=UTF-8';
                        add_header 'Content-Length' 0;
                        return 204;
        }
        # 将客户端的 Host 和 IP 信息一并转发到对应节点  
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        
        # 执行代理访问真实服务器
        proxy_pass http://web;
    }
    
    access_log  /home/wwwlogs/hyperf.log main_log;
}
#------------------------------end


导航栏第三个 go语言的beego框架

server {
    listen       80;
    listen 443 ssl http2;
    server_name  go.zongscan.com;
    charset utf-8;
    access_log  /home/wwwlogs/go.log;
    if ($server_port ~ 443){
        rewrite ^(/.*)$ http://$host$1 permanent;
    }
if ($http_user_agent ~* "ApacheBench|WebBench|Wget|Curl|HttpClient"){ return 444; }
if ($http_user_agent ~* "YisouSpider|baidu|Sogou|spider|360spider|Scrapy|Sogou web spider|Baiduspider|MegaIndex|GrapeshotCrawler|MJ12bot|BLEXBot|MauiBot|AhrefsBot|SemrushBot|Scrapy|YandexBot|DotBot|bingbot"){return 444;}
    location /(css|js|fonts|img)/ {
        access_log off;
        expires 1d;
        root "/gblog/static";
        try_files $uri @backend;
    }
    location / {
        try_files /_not_exists_ @backend;
    }
    location @backend {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;
        proxy_pass http://127.0.0.1:8080;
    }
    location /chat/ws {
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $http_host;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_redirect off;
         proxy_pass http://127.0.0.1:8080;
    }
}

完


  • 上一条:
    TP5框架版本5.0.10安全漏洞根据官方补丁修复,也是本站安全漏洞修复
    下一条:
    laravel5.8如何在数据更新后获取更新前的原始属性方法
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 2024.07.09日OpenAI将终止对中国等国家和地区API服务(0个评论)
    • 2024/6/9最新免费公益节点SSR/V2ray/Shadowrocket/Clash节点分享|科学上网|免费梯子(1个评论)
    • 国外服务器实现api.openai.com反代nginx配置(0个评论)
    • 2024/4/28最新免费公益节点SSR/V2ray/Shadowrocket/Clash节点分享|科学上网|免费梯子(1个评论)
    • 近期文章
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-07
    • 2017-08
    • 2017-09
    • 2018-01
    • 2018-07
    • 2018-08
    • 2018-09
    • 2018-12
    • 2019-01
    • 2019-02
    • 2019-03
    • 2019-04
    • 2019-05
    • 2019-06
    • 2019-07
    • 2019-08
    • 2019-09
    • 2019-10
    • 2019-11
    • 2019-12
    • 2020-01
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-09
    • 2020-10
    • 2020-11
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-04
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-12
    • 2024-02
    • 2024-04
    • 2024-05
    • 2024-06
    • 2025-02
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客