宝塔双11特惠活动,企业版2299元/3年,SSL证书低至9.9元!查看活动
当前位置:论坛首页 > Linux面板 > 求助

【已回应】nginx如何不同目录访问不同端口

发表在 Linux面板2023-1-31 22:09 [复制链接] 1 4954

需求:
1,首先有个zblog一键部署好的一个主站
2,域名下的其他目录需要访问其他端口

比如:http://baidu.com,http://baidu.com/a,这两个目录访问的是zblog主站
http://baidu.com/b,这个目录需要访问端口为8080这个站
这个怎么部署

我是这么加的,看了日志,能访问到buy这,但是显示404,应该如何写呢


server
{
    listen 80;
        listen 443 ssl;
    server_name baidu.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root c:/wwwroot/new.baidu.cn;

   
    location / {
        proxy_pass http://192.168.1.1:8080;
    }
   


        #START-ERROR-PAGE
        #error_page 403 /403.html;
        error_page 404 /404.html;
    #error_page 502 /502.html;
        #END-ERROR-PAGE

    #HTTP_TO_HTTPS_START
    #HTTP_TO_HTTPS_END

    #LIMIT_INFO_START
    #LIMIT_INFO_END

    #SSL-INFO-START
    ssl_certificate    ssl/baidu.cn/fullchain.pem;
    ssl_certificate_key    ssl/baidu.cn/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;
    #SSL-INFO-END




    #反代清理缓存配置
    location ~ /purge(/.*) {
        proxy_cache_purge cache_one $1$is_args$args;
    }
    #proxy 反向代理
    include proxy/baidu.cn/*.conf;

    #PHP-INFO-START
    include php/72.conf;
    #PHP-INFO-END

    #REWRITE-START
    include rewrite/baidu.cn/*.conf;
    #REWRITE-END

    #redirect 重定向
    include redirect/baidu.cn/*.conf;

    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }

        access_log  C:/Users/Administrator/Desktop/baota/BtSoft/wwwlogs/baidu.cn.log;
    error_log  C:/Users/Administrator/Desktop/baota/BtSoft/wwwlogs/baidu.cn.error.log;
}


使用道具 举报 只看该作者 回复
发表于 2023-1-31 23:44:35 | 显示全部楼层
您好,您可参考此链接进行配置
https://www.cnblogs.com/yanzi2020/p/14727151.html
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表