NGINX way to explore https:https://cdn.v2ex.com/navatar/9778/d5d2/82_normal.png?m=1735545287 https:https://cdn.v2ex.com/navatar/9778/d5d2/82_large.png?m=1735545287 2025-09-18T03:31:27Z Copyright © 2010-2018, V2EX oracleusa.ml 的实现原理 tag:www.v2ex.com,2025-09-18:/t/1160074 2025-09-18T01:02:54Z 2025-09-18T03:31:27Z yaocf member/yaocf 很久之前看到的一个有意思的镜像站,把被代理地址放到了 url 参数中,因此可以同时镜像多个网站。它的 url 类似于(服务很久之前就已经访问不了了):
https://oracleusa.ml/-----https://www.google.com/

想请问有没有类似的项目可以推荐一下的?想部署一个看看。

或者这类服务该用什么关键词搜?

感觉有点像虚拟浏览器了都。

]]> 尝试自己配置转发后端请求的时候有个疑问 tag:www.v2ex.com,2025-09-09:/t/1158023 2025-09-09T06:39:16Z 2025-08-20T12:48:49Z puremaker member/puremaker 首先这个是前端项目页面的配置,没啥问题,

location / { root /home/party_game/dist; # 访问根目录 index index.html index.htm; # 入口文件 try_files $uri $uri/ /index.html; } 

然后正常情况转发后端请求应在再写一个 location 拦截,也就是这样

location /api { proxy_pass http://localhost:60101; } 

看着也没啥问题是吧?但是震惊我的是,我在前端项目和后端项目里配置的请求地址前缀都是 pgApi (例: http://localhost:60101/pgApi/auth/login ),如此我又尝试了把请求拦截换成了

location /abc { proxy_pass http://localhost:60101; } 或者 location /xxxx { proxy_pass http://localhost:60101; } 

但是 nginx 都能把前端请求正常的转发到后端服务上,这个是为什么呀? 有点无法理解这部分原理,网上也没有搜到比较符合我问题的答案,特来请教

]]>
请教 Nginx 时完整的 SSL 刷新教程或者脚本 tag:www.v2ex.com,2025-08-06:/t/1150489 2025-08-06T13:24:38Z 2025-08-07T08:01:37Z fhrui0706 member/fhrui0706 请教 Nginx 时完整的 SSL 刷新教程或者脚本,例如证书已经申请,前辈一般是怎么做的

]]>
问问大家 nginx 日志流量分析用什么方案? tag:www.v2ex.com,2025-08-04:/t/1149876 2025-08-04T10:46:34Z 2025-08-04T23:46:54Z deqiying member/deqiying 现在项目的部署有点乱,头大,小白来求救了
1.每台服务器都部署有不同的项目,日志都是打到 access.log (没有按项目划分)
2.一个项目可能在不同服务器都有节点,也就是是一个项目的访问日志可能在两个 access.log 中
3.同一个项目可以通过域名或者 path 区分

这种奇怪的部署方式有方案能收集日志并按项目进行统计划分吗?小项目,方案轻量点好,AI 让引入 ELK 栈部署,比项目本身都复杂了。
小白一个,恳请各位大佬指点。 ]]>
nginx 二级目录反向代理是不是有先天缺陷? tag:www.v2ex.com,2025-08-04:/t/1149767 2025-08-04T04:29:16Z 2025-08-04T10:26:45Z kyonn member/kyonn 如下一个最简化的反代配置,将本地 80/443 端口的 /git/ 反代到本地容器的 8085 端口。

访问 127.0.0.1/git/ 成功跳转到 8085 端口容器的 web 页面,但是发现有诸多问题:

  1. css 和 png 加载失败。抓了下调试信息,发现是容器返回的样式等文件地址都是绝对路径 /,进而导致浏览器请求样式文件时,没有正确走 location /git/ 的反代。通过 sub_filter 指令批量替换后解决了。
  2. 问题 1 解决后,点击其它页面元素,还是会出现 404 错误。原因同 1

类似这种二级目录的反向代理,是不是天然有缺陷,没办法像 二级域名 或 三级域名 反代那样完美实现?

注:

  1. 域名管理不在手上,添加多个二级或三级域名比较麻烦,所以考虑的是同一个域名下的子目录。
  2. 可以修改反代 upstream docker 的配置,因为是自己部署的。
location /git/ { proxy_http_version 1.1; proxy_pass http://192.168.1.13:8085/; } 
]]>
nginx rewrite 指令的问题 tag:www.v2ex.com,2025-08-02:/t/1149519 2025-08-02T14:04:33Z 2025-08-02T19:44:46Z kyonn member/kyonn 手头没有现成的测试环境,AI 的回答感觉也不太靠谱,咨询下 V 友 关于 nginx rewrite 指令的问题:

一、rewrite 指令的正则表达式是部分匹配还是完全匹配才生效?

比如下面的配置中,请求 /name/jane-lotus 肯定会触发 rewrite 指令,最终请求地址为 http://user-center/users?name=jane-lotus 。

那么请求 /name/regions/bbb 会不会触发 rewrite 的 URI 替换?最终请求地址是多少?

这篇文章说不会触发 rewrite ,AI 的回答是会触发 rewrite 。

location /name/ { rewrite /name/([^/]+) /users?name=$1 break; proxy_passs http://user-center/main/basicinfo/; } 

二、还是上面的配置,假如原始请求里带了查询参数,那么触发 rewrite 后会不会把原始请求参数也追加给新的请求地址? rewrite 新目标里有没有新的查询参数是否会影响老的查询参数追加到最终请求里?

三、是否有比较系统的 nginx 配置教程推荐或者模拟测试环境验证 nginx 详细执行过程的方法?

]]>
问个 nginx 配置问题 tag:www.v2ex.com,2025-08-01:/t/1149311 2025-08-01T07:44:12Z 2025-08-01T09:37:31Z kyonn member/kyonn 抄来的 nginx 配置,第 1 个 location 的正则表达式不太确定是否正确。按照 AI 的解答,用于匹配下面这几种路径。实测下来,http git clone 也是失败的,未匹配第 1 个 location 。有几个疑点:

  1. 类似这种多行的正则,每一行之间是什么关系?按照 AI 的解答看上去是或的关系,但是没找到正则规则的依据。
  2. 每一行正则结尾是 空格 + 单引号,这个不知道又是什么规则?
 location ~ "(?x)^/git(?<path>/.*/(?:HEAD ' info/refs ' objects/(?:info/[^/]+ ' [0-9a-f]{2}/[0-9a-f]{38} ' pack/pack-[0-9a-f]{40}\.(?:pack ' idx)) ' git-upload-pack))$" { error_page 491 = @auth; if ($query_string = service=git-receive-pack) { return 491; } client_max_body_size 0; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; include fastcgi_params; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param GIT_PROJECT_ROOT /srv/git; fastcgi_param PATH_INFO $path; fastcgi_param REMOTE_USER $remote_user; fastcgi_pass unix:/var/run/fcgiwrap.socket; } location ~ "^/git(?<path>/.*/git-receive-pack)$" { error_page 491 = @auth; return 491; } location @auth { auth_basic "Git write access"; auth_basic_user_file /srv/git/.htpasswd; client_max_body_size 0; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; include fastcgi_params; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param GIT_PROJECT_ROOT /srv/git; fastcgi_param PATH_INFO $path; fastcgi_param REMOTE_USER $remote_user; fastcgi_pass unix:/var/run/fcgiwrap.socket; } location ~ ^/git(?<path>/.*)$ { alias /usr/share/cgit; try_files $1 @cgit; } location @cgit { include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; fastcgi_param PATH_INFO $path; fastcgi_param QUERY_STRING $args; fastcgi_param HTTP_HOST $server_name; fastcgi_param CGIT_CONFIG /srv/git/.cgitrc; fastcgi_pass unix:/var/run/fcgiwrap.socket; } 
]]>
请问下为啥微信客户端访问到 nginx 没有参数了? tag:www.v2ex.com,2025-06-25:/t/1140901 2025-06-25T04:40:11Z 2025-06-25T07:50:18Z zhazhibao member/zhazhibao 例如微信 APP 中点击 a.cn/10003 ,到 nginx 层没有了 10003 参数?

]]>
有兄弟们用 nginx proxy manager(或者其他图形化工具)来管理 nginx 反向代理的吗? tag:www.v2ex.com,2025-05-14:/t/1131690 2025-05-14T06:05:35Z 2025-05-15T02:28:54Z baalchina member/baalchina 有兄弟们用 nginx proxy manager (或者其他图形化工具)来管理 nginx 反向代理的吗?

我们的主要需求是反向代理,现在用 nginx 在跑。因为日常运维的同事对命令行不太熟,操作也麻烦,想通过 gui 工具来进行管理,因为之前遇到过好几次命令行操作失败不小心改错了。

现在主要担心的是第一个 npm 好像内置了 openresty ,似乎单独升级都不是太方便。第二这个东西毕竟套了一层 docker 容器,不知道稳定性如何,万一崩了不像普通 nginx 那么容易恢复。

或者有其他类似的工具可以推荐不?主要需求其实就是通过 gui 界面,能减少日常配置的工作复杂度和出错几率。

谢谢!

]]>
请问 Nginx 怎么添加 CORS 白名单? tag:www.v2ex.com,2025-04-01:/t/1122559 2025-04-01T06:06:42Z 2025-04-01T08:56:48Z whereFly member/whereFly 比如 a.com 下的图片、js 文件等等,只允许 b.comc.com 调用。 其他域名调用的话就显示 404 或者 403 。

]]>
使用 nginx 监听已被监听的端口, reload 不会失败, 但会导致其他配置不生效. tag:www.v2ex.com,2025-03-21:/t/1120174 2025-03-21T08:11:50Z 2025-03-11T20:33:09Z vincentWdp member/vincentWdp 先叠甲: 我是业余运维.

昨天, 在宝塔上对线上服务 A 修改 proxy_pass, 端口从 7511 改成 7501:

location / { proxy_pass http://localhost:7501; } 

更新配置后, 错误日志显示 upstream 依旧是 127.0.0.1:7511, 询问 AI, 反复折腾后, 依旧没能解决. 但在此期间, 没有任何报错, 包括在宝塔上保存配置, 在服务器上 nginx -t, nginx -s reload, nginx -T 等.

推测配置被缓存了, 但为什么被缓存, 不清楚. 只能先重启 nginx 把服务搞上线.

重启之前就隐隐觉得这次重启肯定不顺利, 毕竟 nginx -s reload 没有生效, 有些地方肯定有问题. 果然报错: 7503 端口被占用, nginx 无法启动.

我瞬间就慌了, 在做了两次无效重复后, 理智回来了: nginx -T 查出 7503 在服务 B 的配置文件, 果断注释那一行然后成功启动 nginx, 线上服务恢复, 服务 A 也正常了.

7503 端口本身就被一个 next.js 项目占用, 但不知道为什么还要写到 nginx 配置文件, 只能认为不会 nginx. 问了前端负责人, 到现在也没回我~~

nginx version: nginx/1.20.2

]]>
nginx 如何获取/打印完整代理路径? tag:www.v2ex.com,2025-03-21:/t/1120024 2025-03-21T01:24:28Z 2025-03-21T06:13:18Z a33291 member/a33291 location /test {
proxy_pass http://localhost/
}
当请求 /test/api?a=1 时 实际向上游发起的地址为 http://localhost/api?a=1
这由 nginx 的内置机制自动完成

现在,是否有 nginx 变量或者其他方案可以获取到这个 http://localhost/api?a=1 (目前是人工算的)

如果自己利用 $uri $request_uri 之类的拼接很麻烦 ]]>
Nginx 四层反代 QUIC 如何传递客户端 IP tag:www.v2ex.com,2025-03-14:/t/1118432 2025-03-14T06:18:13Z 2025-03-14T17:05:35Z dabao member/dabao 使用 nginx 的四层代理监听 443 端口,反代后端 6443 端口站点。 通过http2可以正常获取到客户端 IP ,通过 h3quic连接则无法获取到真实的客户端 IP ,只能获取到 127.0.0.1 。

请问各位大佬,在保持使用四层反代的前提下,如何配置可以通过quic获取到客户端 IP 。

使用 quic 连接获取到的 IP

REMOTE_ADDR: 127.0.0.1 HTTP_CLIENT_IP: 未设置 HTTP_X_FORWARDED_FOR: 未设置 HTTP_X_REAL_IP: 未设置 HTTP_FORWARDED: 未设置 HTTP_FORWARDED_FOR: 未设置 HTTP_X_FORWARDED: 未设置 

四层 stream 配置

map $ssl_preread_server_name $name { default default_backend; } upstream default_backend { server 127.0.0.1:6443; # 站点 } server { listen 443 reuseport; listen 443 udp reuseport; proxy_pass $name; ssl_preread on; proxy_protocol on; } 

站点配置

server { listen 80; listen 6443 ssl proxy_protocol ; listen 6443 quic reuseport; http2 on; server_name abc.com www.abc.com; index index.php index.html; root /wwwroot/abc.com; set_real_ip_from 127.0.0.1; real_ip_header proxy_protocol; ... } 
]]>
关于 windows 下面重启之后 nginx 的问题 tag:www.v2ex.com,2025-03-09:/t/1117051 2025-03-09T08:08:15Z 2025-03-09T09:37:54Z chenqh member/chenqh
  • 现在我有一个笔记本,里面有个虚拟机,虚拟机里面部署了我的 sphinx 文档.

  • 然后在外面笔记本 windows 系统上面启动 nginx,反代虚拟机的 sphinx 文档站点.

  • 然后我笔记本开机会自动启动虚拟机,nginx.

    现在问题来了,我笔记本重启,虚拟机也重启好了,

    我在台式机上访问 nginx 的反代的 sphinx 文档站点,提示 502?一定要我去把 nginx 再重启一下,502 才消, 这种问题怎么解决?

    还有一个问题,我笔记本重启后,有时候一段时间后会陷入黑屏状态,但是我明明设置了电源状态为不黑屏啊? 这种问题又如何解?

    ]]>
    我是不是可以反向代理个 V2EX 网站? tag:www.v2ex.com,2025-02-25:/t/1114042 2025-02-25T03:16:39Z 2025-02-25T04:15:49Z Gnepre member/Gnepre 自己辛苦运营的站点被人反向代理,如何避免自己站点被人反向代理? ]]> 用 nginx 做的 xai 的转发好像一直有问题 tag:www.v2ex.com,2025-02-17:/t/1112077 2025-02-17T09:09:31Z 2025-02-17T09:19:15Z vacuitym member/vacuitym 同样的配置 openai 和 claude 就没问题:

     location /xai { proxy_pass https://api.x.ai/; proxy_ssl_server_name on; proxy_set_header Host api.x.ai; proxy_set_header Connection ''; proxy_http_version 1.1; chunked_transfer_encoding off; proxy_buffering off; proxy_cache off; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; } 

    请求:

    https://chat.xxxxx.com/xai/v1/chat/completions

    报错:

    { "code": "Some requested entity was not found", "error": "No handler found on route. Please double check your URL and consult https://api.x.ai/docs for more information." } 
    ]]>
    请教一个 Nginx 配置和浏览器强制 http 转 https 问题 tag:www.v2ex.com,2025-02-12:/t/1110841 2025-02-12T02:05:02Z 2025-02-12T09:42:47Z coolair member/coolair
    在浏览器中访问没有启用 https 的域名,会强制跳转到 https ,导致解析到启用了 https 的网站,而不是自己 http 的网站。

    这个有没有办法在不修改客户端浏览器的情况下解决? ]]>
    nginx proxy manager ipv6 反代指向内网 ipv4 局域网地址,还可以这样操作🤔? tag:www.v2ex.com,2025-02-06:/t/1109395 2025-02-06T09:11:37Z 2025-02-08T15:53:31Z lengrongec member/lengrongec 在家里玩客云上用 docker 部署了它和 adguard ;
    无意间发现可以只要把 npm 的 docker 网络由 bridge 改为 host 主机模式,如果使用 ddns 解析到 ipv6 ,在做反代的时候内网可以使用局域网的 ipv4 地址。这样不影响外网的 ipv6 访问。可以精准访问内网服务 ]]>
    关于 Nginx 反向代理性能调优的问题,求指导🙏 tag:www.v2ex.com,2025-01-20:/t/1106475 2025-01-20T06:32:25Z 2025-01-21T18:10:18Z yumerdev93 member/yumerdev93 以下环境均在 docker 中,nginx 用 host network 。

    我现在在用 Nginx 代理一个 Fastapi 应用,从局域网内其他机器通过wrk直接压测后端应用的一个简单返回,在 8 核 CPU 上有 4w QPS ,但通过 Nginx 代理 Fastapi 后,QPS 只有离谱的 2-3k ,我看后端机器 CPU 是没有跑满的,Nginx CPU 反而是占用满了。

    压测结果:

     2 threads and 200 connections Thread Stats Avg Stdev Max +/- Stdev Latency 115.25ms 86.47ms 712.60ms 45.32% Req/Sec 0.91k 1.01k 3.74k 87.67% 27096 requests in 15.02s, 9.25MB read Requests/sec: 1804.16 Transfer/sec: 630.75KB 

    上面操作均在 3 台局域网内机器,实际上在 Nginx 机器通过 curl 访问后端也只是 2ms 的延迟,请求这问题是出在哪儿了呢? Nginx 使用的是默认配置,没经过优化。

    另外,通过 docker 部署 traefik 反向代理后压测,后端能正常跑满 CPU ,延迟也是正常的几毫秒之内,就是 traefik CPU 占用也挺大的,按道理来说 Nginx 性能应该强于 traefik 吧?

    这个问题困扰了我好几天了,问 GPT Nginx 优化相关的也只是反复回答链接数、keep alive 这些,都试过了没作用,请问各位大哥 Nginx 应该怎么配置优化呢?

    ]]>
    nginx 配置根据请求头分发问题 tag:www.v2ex.com,2025-01-13:/t/1104759 2025-01-13T08:46:39Z 2025-01-13T09:54:39Z exqibao member/exqibao 根据请求头分发

    loc: /aa ==> http://127.0.0.1:28080/aa

    pro: /aa ==> http://127.0.0.1:8011/api/

    其它: /aa ==> http://127.0.0.1:8022/api/

    大佬们,原来只有 loc 和其它一切正常,加上 pro 就不行了,如何配置可以实现这个效果吗?似乎 if 里面 proxy_pass 不能有/api/地址

     location /aa { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; if ($http_environment_name = "loc" ) { proxy_pass http://127.0.0.1:28080; break; } if ($http_environment_name = "pro" ) { proxy_pass http://127.0.0.1:8011/api/; break; } proxy_pass http://127.0.0.1:8022/api/; } 
    ]]>
    用过 nginx-proxy-manager 请进, 咨询个问题. tag:www.v2ex.com,2025-01-11:/t/1104384 2025-01-11T11:46:24Z 2025-01-20T19:05:31Z kyonn member/kyonn 最近看到不少 nginx-proxy-manager 的推荐, 它能不能支持 https://github.com/nginx-proxy/nginx-proxy 提供的功能, 只要在其他 docker-compose.yml 中指定 VIRTUAL_HOST 和 VIRTUAL_PORT, 就能二级域名反代到其他 docker, 甚至是反代多个 docker 内部端口.

    nginx-proxy-manager 相比于 nginx-proxy 有什么优势吗? nginx-proxy-manager 能自动帮其他 docker 反代端口吗?

    ]]>
    我有一个端口转发问题,求大佬们协助 tag:www.v2ex.com,2025-01-09:/t/1103834 2025-01-09T03:15:21Z 2025-01-09T19:33:15Z AndreasG member/AndreasG 我现在有三个容器开着,路由器开放了三个端口, 我想能不能开放一个端口用拼接 url 方式转发到不同的内网服务下,

    server { listen 10086 ssl; server_name abc.com; location / { proxy_pass http://192.168.0.100:10086; proxy_set_header Host $host; 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 $scheme; } location /book { proxy_pass http://192.168.0.100:10010; proxy_set_header Host $host; 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 $scheme; } } 

    类似这样配置了 nginx 之后 直接访问 abc.com:10086 端口访问全部没问题 但是转发的第二个端口

    abc.com:10086/book 

    并不能成功转发到 192.168.0.100:10010 浏览器调试发现使用 abc.com:10086/book 发出的请求中 css js 之类的都是

    abc.com:10086/static/?.css abc.com:10086/static/?.js 

    而并没有到

    abc.com:10086/book/static/?.css abc.com:10086/book/static/?.js 

    状态都是 404 了 问了一下 gpt 说是需要找到真实的静态资源地址,这个容器的话怎么搞呢?还是说我的 nginx 需要配置其他配置项才可以呢,求大佬们帮助

    ]]>
    使用 Nginx 代理 Emby 服务器,浏览器可以访问但是客户端连不上 tag:www.v2ex.com,2024-12-23:/t/1099518 2024-12-23T01:47:09Z 2024-12-23T10:14:06Z ShimaKazeLiu member/ShimaKazeLiu
    整个链路就是我家->服务器->外网

    然后网址是阿里云买的,dns 解析到了 cf

    cf 添加了一个 emby 的 dns 记录 指向了这个服务器

    然后在 nginx proxy manager 配了一条 ssl 证书用的 Let's Encrypt

    现在的结果就是我通过网址用浏览器访问我家的 Emby 是没问题的,但是我用 APP 访问那就连接不上

    这个是不是 APP 的问题,有没有 Emby 的大佬帮我看看 ]]>
    小白在使用 Nginx proxy manager 遇到问题,请大佬们指教。 tag:www.v2ex.com,2024-12-21:/t/1099224 2024-12-21T02:21:12Z 2024-12-21T08:42:52Z ezekiel222 member/ezekiel222 npm 用 docker-compose 部署在 openwrt 上,network 是 bridge (网关 172.17.0.1 )。npm 可以反代同网关的 ddns-go 等 docker 容器(网关 172.17.0.1 ),和 openwrt (地址 192.168.66.1 ),但是不能反代群晖 nas (地址 192.168.66.4 ),是因为 npm 用 bridge 没用 host 的原因吗?如果是,请问是否有不改变 bridge 能反代 nas 的方法?

    ]]>
    请教下 nginx 反代配置 tag:www.v2ex.com,2024-12-16:/t/1097996 2024-12-16T11:46:35Z 2024-12-16T15:05:39Z andyfan member/andyfan 我想自建一个 docker 的镜像源, 写了个配置文件反代 registry-1.docker.io, 同时希望访问这个域名根路径的时候不要反代, 返回网站目录下的 index.html

    但我的配置文件没有按照预期那样工作, 直接访问域名根路径的时候还是反代到了 registry-1.docker.io 导致返回 404, 希望有熟悉 nginx 的老哥帮忙看看, 这要怎么修改?

    我的 server 配置如下

     location = / { add_header Cache-Control private; alias /var/www/html/; index index.html; } location / { # Docker hub 的官方镜像仓库 proxy_pass https://registry-1.docker.io; proxy_set_header Host registry-1.docker.io; 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 $scheme; # 关闭缓存 proxy_buffering off; # 转发认证相关 proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; # 对 upstream 状态码检查,实现 error_page 错误重定向 proxy_intercept_errors on; recursive_error_pages on; # 根据状态码执行对应操作,以下为 381 、302 、387 状态码都会触发 error_page 301 302 307 = @handle_redirect; } 
    ]]>
    nginx 配置问题求解答 tag:www.v2ex.com,2024-12-05:/t/1095330 2024-12-05T12:11:58Z 2024-12-05T13:11:58Z gotonull member/gotonull 问题描述:a 服务器的 nginx 服务会将 /aisp/approval/ 路径的请求转发给我,我收到请求后根据user-agent判断是移动端还是 pc 端请求,如果为移动端的,则去当前服务器的/home/centos/web/h5目录下响应对应的静态文件。如果是/aisp/approval/api/路径下的请求则请求后端服务,当前的配置:

    server { listen 9999; server_name localhost; location /aisp/approval/ { if ($is_mobile = 0) { rewrite ^/aisp/approval/(.*)$ https://b.com/$1 permanent; } alias /home/centos/web/h5/; try_files $uri $uri/ /index.html; } location /aisp/approval/api/ { limit_conn perip 1000; proxy_pass http://10.156.166.23:9088/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; client_max_body_size 600M; client_body_buffer_size 512k; } } 

    现在的问题是通过移动端请求a.com/aisp/approval/workOrder/orderHandlerDetails,error.log 会报:

    open() "/usr/local/nginx/html/home/centos/supervision/web/h5/index.html" failed (2: No such file or directory) 

    /usr/local/nginx/html 是我 nginx 的安装目录,我要如何配置才能在请求 a.com/aisp/approval/workOrder/时响应/home/centos/supervision/web/h5/目录下的 index.html

    ]]>
    Nginx 流量异常,请大佬支招~ tag:www.v2ex.com,2024-12-05:/t/1095168 2024-12-05T02:59:08Z 2024-12-05T07:20:55Z jalena member/jalena 之前一直好好的,今天突然收到流量告警。

    使用 NetHogs 查看流量发现 unknown TCP 的 RECEIVED 一直居高不下,停掉 docker 内的 nginx 就正常了,目前只放了一个空的页面这个流量也很高。

    请大佬支支招,如何排查呢。系统是 debian12 ,程序都安装在 docker 内

    ]]>
    nginx 读取 ssl 证书的权限问题请教 tag:www.v2ex.com,2024-12-03:/t/1094763 2024-12-03T11:40:42Z 2024-12-04T00:20:12Z raysonlu member/raysonlu
    但实测并不能,nginx 处理访问触发读取 ssl 证书的时候,会报错无权限读取 ssl 证书,摸索了一番后,发现只有把证书拥有者改为 nobody ,nginx 才能读取并正常处理访问。

    “进程的拥有者只能读取自己拥有的证书”?这与理解的 linux 文件权限读取逻辑有点不一样,这是 linux 内核对这种操作的特殊处理,还是 nginx 自己定的规则? ]]>
    请问一个二级域名如何配置可以访问多个 http 服务? tag:www.v2ex.com,2024-12-03:/t/1094593 2024-12-03T02:29:40Z 2024-12-03T20:34:53Z maninnet member/maninnet 我手上只有一个二级域名 sub.abc.com ,但我有一个 alist 和 nas 的 http 服务想通过这个二级域名进行访问,比如 sub.abc.com/alistsub.abc.com/nas 分别访问 alist 和 nas 的管理后台,我尝试通过 nginx 配置 location 的 rewrite 和 sub_filter 都没办法解决,请问有什么解决办法吗?

    ]]>
    配置证书相关的问题 tag:www.v2ex.com,2024-11-28:/t/1093382 2024-11-28T06:17:08Z 2024-11-28T12:50:09Z AndreasG member/AndreasG 手上的资源
    1. 我家只有一条家用宽带意味着我无法使用 80 、443 端口
    2. 家里是动态 ip ,带 ipv4 公网
    3. 公网访问的方法:使用了 tplink 路由器自带的的 tpddns 直接生成的域名
    4. 端口转发使:由于宽带原生支持公网,所以直接开放的端口
    5. 目前在用的公网访问方式: 因为 tpddns 的域名有点长用着麻烦,而刚好我阿里云上还有个闲置的域名,目前是直接解析到 tpddns 域名上用了
    6. 我在阿里云申请了免费的 3 月有效期证书
    7. 家里 Esxi 开了一个群晖和两个 linux 虚拟机

    目前的需求

    我想实现在一台 Linux 虚拟机上配置 nginx ,用于代理家里这三台虚拟机上的服务,可以实现 https 访问 

    目前遇到的问题

    1. 我申请签发的时候使用了闲置的阿里云域名,秒通过,但是配置了 nginx 之后访问不通(有可能是没配置好,或者是因为二次解析的域名,到达 tpddns 域名的时候就失效了,这部分没怎么测试,昨晚刚申请的)
    2. tpddns 作为域名申请阿里云签发的时候被拒绝了,原因貌似是因为没有 80 和 443 端口

    问题

    1. 我是否可以在一台机器上配置 ngixn 服务用于代理所有家里的服务,因为三台虚拟机的 ip 都不同,如何保证请求是直接发送给 nginx 而不是直接发送到对应的虚拟机上呢
    2. 我的思路很混乱,不太懂 nginx 的代理流程,目前这种两个域名的情况我应该申请签发哪个域名的证书呢
    3. 如果签发完成我需要在 nginx 代理中监听的域名是 阿里云的域名还是 tpddns 的域名呢
    ]]>
    关于 nginx 的一些提问 tag:www.v2ex.com,2024-11-27:/t/1093078 2024-11-27T06:10:26Z 2024-11-27T12:13:46Z myangshu member/myangshu 搞了个服务器,搭建了一些东西,但是在不同端口,想着用 nginx 做个反代可以全走一个端口,但是代理过后转发的包总是还有原来的路径,比如东西在 30 端口,访问就是

    http://localhost:30

    但是转发过去就变成了

    http://localhost/abc/

    请问这个有什么解决办法嘛?

    ]]>
    nginx 限流失败的奇怪问题 tag:www.v2ex.com,2024-11-25:/t/1092345 2024-11-25T03:33:45Z 2024-11-29T09:24:40Z dunhanson member/dunhanson 问题描述

    ~/info 限流失败

    ~info 和~/info 都能匹配到值,$limit_key_pc_page_info 的值输出 page_info

    为什么加/符号会影响限流?$limit_key_pc_page_info 里面有值

    1 、nginx 配置

    # 变量-URI map $uri $limit_key_pc_page_info { ~/info "page_info"; #~info "page_info"; default ""; } limit_req_zone $limit_key_pc_page_info zOne=limit_zone_pc_page_info:10m rate=1r/s; server { listen 80; server_name www.dunhanson.com; charset utf-8; location / { # 限流 limit_req zOne=limit_zone_pc_page_info nodelay; proxy_pass http://www_dunhanson_com; } } server { listen 80; server_name test.dunhanson.com; charset utf-8; location / { default_type text/plain; return 200 "$uri $limit_key_pc_page_info"; } } 

    2 、测试效果

    curl http://test.dunhanson.com/info-558860051.html 

    输出: /info-558860051.html page_info

    ]]>
    反向代理提示该网站已被拦截,请教 tag:www.v2ex.com,2024-11-21:/t/1091390 2024-11-21T01:51:48Z 2024-11-21T03:34:24Z awanganddong member/awanganddong 域名是在阿里云,服务器 a 也是在阿里云。 然后通过反向代理指向本地服务器 b 。

    如果在 nginx 配置中增加下边几项就报上边的错误。

     proxy_set_header Host $host; 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 $scheme; 

    如果去除这几项就正常了。

    所以想请问下,这种情况是怎么造成的。不理解。

    ]]>
    为什么我的 docker nginx 的不能反向代理 favicon 啊 tag:www.v2ex.com,2024-11-06:/t/1087129 2024-11-06T06:28:16Z 2024-10-27T06:34:37Z importmeta member/importmeta docker 环境下, 外部有个 nginx 反向代理, 代理了一个内部的 nginx.

     # 不加这一条就无法反向代理 favicon 日志 404 location = /favicon.ico { log_not_found off; proxy_pass http://official; } location / { proxy_pass http://official; proxy_set_header Host $host; } 

    我内部的 official 的 nignx 直接用端口访问, 是能看到 favicon 的.

    试了好久才发现, 外部必须再写一条, 才能看到 favicon, 但是我不写 css 什么的, css 直接就没问题, 只有 favicon 有这个问题.

    问过 AI 了, 老是照着结果回答.

    为什么啊? 谢谢各位了.

    ]]>
    Nginx 能不能实现按域名限制网速? tag:www.v2ex.com,2024-11-05:/t/1086681 2024-11-05T01:35:01Z 2024-11-05T04:18:53Z waringid member/waringid a.example.com -> 192.168.1.10:3000
    b.example.com -> 192.168.2.10:8900

    想要实现的效果:
    a.example.com 限制访问带宽为 2M (外网访问,不限制访问 192.168.1.10 )
    b.example.com 限制访问带宽为 3M (外网访问)
    其它的域名不限制

    尝试过的方案:
    1 、防火墙或网关限制(只能基于 IP 限制,而且不灵活)
    2 、Nginx 自带的访问频率和访问速率控制 (有一定效果,不够灵活并且如果是已建立的连接,限制带宽操作不生效,需要断开本次连接,重新再连时才生效)

    各位大佬有没有更灵活的实现方案推荐? ]]>
    请教一下各位关于 nginx 版本更新区别导致反向代理无法访问的问题 tag:www.v2ex.com,2024-11-01:/t/1085831 2024-11-01T09:58:43Z 2024-11-02T11:58:26Z KadeDivent member/KadeDivent 迁移了一个 headscale 服务端,反向代理配置了 headscale-ui 的静态页面

    我将 centos 7 中的 nginx v1.20.1 配置迁移到了 rocky linux 9 中的 nginx v1.26.2 中,

    使用的均为 rpm 包

    nginx v1.20.1 是官方源中下载

    nginx v1.26.2 是从 nginx 源中下载


    迁移之后 headscale 被反向代理后的 8082 端口就无法访问了,但是原生的 8080 端口可以访问,

    两个站点配置完全一样,是直接复制过去的

    新版本的 nginx 日志中没有相关访问日志

    并且 nginx 的主要更新日志,并没有什么头绪,所以发帖请教一下各位


    以下是日志与配置

    站点主要配置如下

    server { listen 8082 ssl ; listen [::]:8082 ssl ; server_name xxxx; root /opt/headscale/headscale-ui/web; # SSL ssl_certificate /etc/nginx/cert/xxxx.crt; ssl_certificate_key /etc/nginx/cert/xxxx.key; ssl_protocols TLSv1.2 TLSv1.3; # logging # 这里其实有日志配置,但是不知道放进来就不能发帖 location /web { alias /opt/headscale/headscale-ui/web; index index.html; } # reverse proxy location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $server_name; proxy_redirect http:// https://; proxy_buffering off; 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 $http_x_forwarded_proto; add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always; } } 

    headscale 的部分日志如下

    Nov 01 17:13:17 xxxxxx tailscaled[2145341]: control: LoginInteractive -> regen=true Nov 01 17:13:17 xxxxxx tailscaled[2145341]: control: doLogin(regen=true, hasUrl=false) Nov 01 17:13:17 xxxxxx tailscaled[2145341]: Received error: fetch control key: Get "https://xxxxxx:8082/key?v=106": read tcp 192.168.2.199:36346->xx.xx.xx.xx:8082: read: connection reset by peer Nov 01 17:13:17 xxxxxx tailscaled[2145341]: health(warnable=login-state): error: You are logged out. The last login error was: fetch control key: Get "https://xxxxxx:8082/key?v=106": read tcp 192.168.2.199:36346->xx.xx.xx.xx:8082: read: connection reset by peer 

    nginx 的版本信息如下

    旧服务器

    nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.1.1k FIPS 25 Mar 2021 TLS SNI support enabled 

    新服务器

    nginx version: nginx/1.26.2 built by gcc 11.4.1 20231218 (Red Hat 11.4.1-3) (GCC) built with OpenSSL 3.0.7 1 Nov 2022 TLS SNI support enabled 

    详细的编译参数放不进去,如果有需要的话,后续考虑截图放在后面

    ]]>
    虚心请教一个有关于 nginx 配置的问题 tag:www.v2ex.com,2024-10-24:/t/1083249 2024-10-24T06:44:20Z 2024-10-26T17:09:44Z xiaochena member/xiaochena 在请求如 /_next/static/media/page-main-image.0b61c706.png 这样的文件时

    这段配置可以正常运行

     location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ { rewrite /_next/(.*) /.next/$1 break; try_files $uri $uri/; expires 1y; # 设置缓存时间为 1 年 add_header Cache-Control "public"; } 

    这段配置却找不到文件、响应体还会变成 308 重定向

     location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ { alias /app/.next/static/; # 将请求路径 /_next/static/ 映射到文件系统的 /app/.next/static/ expires 1y; # 设置缓存时间为 1 年 add_header Cache-Control "public"; } 
    ]]>
    求解 nginx 反代某堡垒机 443 页面出现问题 tag:www.v2ex.com,2024-10-16:/t/1080932 2024-10-16T11:29:55Z 2024-10-16T11:32:33Z LeeLou member/LeeLou 某堡垒机可以用网页 h5 页面运维 ssh 登录的资产,或是 rdp 登录的 windows 资产。运维 ssh 资产时,url 为/access/h5/tool/ssh/operate_id/d928d8570b97XXX , 运维 rdp 资产时,url 为/access/h5/tool/vnc/operate_id/d928d8570b97XXX 。

    使用 nginx 反代堡垒机的 443 端口,登录堡垒机,运维 rdp 资产都没问题。 但运维 ssh 资产时,显示权限不对,登录失败。

    两种资产都是用密码登录的,url 在反代前和反代后,感觉也没有区别。

    ]]>
    nginx if 语句 return 403,没办法跳转自定义 403 页面 tag:www.v2ex.com,2024-09-02:/t/1069698 2024-09-02T10:13:41Z 2024-09-02T10:20:24Z dunhanson member/dunhanson nginx if 语句 return 403 ,没办法跳转自定义 403 页面

    返回的 403 还是 nginx 自带的 403 页面

    error_page 403 /403.html; location = /403.html { root D:/program/nginx/nginx-1.18.0/html; } if ($http_user_agent ~ "Baiduspider") { return 403; } 
    ]]>
    请教 nginx deny 优先级的问题。 tag:www.v2ex.com,2024-08-30:/t/1069052 2024-08-30T06:57:12Z 2024-08-31T03:52:21Z ab member/ab http{ deny 192.168.6.8; ... server { listen 443 ssl; http2 on; server_name example.com; ... if ($http_user_agent ~* "curl") { return 406; } } } 客户端 192.168.6.8 使用 curl -I example.com 时,返回 406 ,难道 if 比 http 段的 deny ip 的优先级还高吗?

    ]]>
    求教关于反代的问题 tag:www.v2ex.com,2024-08-24:/t/1067478 2024-08-24T07:14:58Z 2024-08-25T04:51:32Z Aicnal member/Aicnal 之前部署了一个 Discourse 站点 部署在一台配置比较高但是线路没有优化的机器上 容器内部使用 nginx 然后通过 Unix Socket 使用宿主机的 Caddy 进行域名访问 之后我在线路比较好的香港服务器上部署 Nginx 对原站进行反代 但是反代后为502,无法正常访问 我看了下error.log说的是代理服务器和源站 ssl 握手失败 但是我在代理服务器里面写的是https,而且代理服务器curl能正常获取到内容 这个是源站的caddyfile

    direct.example.com { reverse_proxy unix//var/discourse/shared/standalone/nginx.http.sock { header_up Host {host} header_up X-Real-IP {remote} header_up X-Forwarded-For {remote} header_up X-Forwarded-Proto {scheme} } header { Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" } } synapse.know-cnu.wiki { reverse_proxy localhost:8008 { # WebSocket 连接的默认配置 header_up Host {host} header_up X-Real-IP {remote} header_up X-Forwarded-For {remote} header_up X-Forwarded-Proto {scheme} # 处理 WebSocket 连接 transport http { read_buffer 0 } } # 设置 HSTS 头部 header { Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" } 

    这个是代理服务器的nginx.conf,未使用ssl

    server { listen 80; server_name example.com; location / { proxy_pass https://direct.example.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; proxy_set_header X-Forwarded-Proto $scheme; } } 

    error.log如下

    root@VM80459:~# tail -f /var/log/nginx/error.log 2024/08/24 06:08:57 [emerg] 3325#3325: "server" directive is not allowed here in /etc/nginx/nginx.conf:11 2024/08/24 06:09:05 [emerg] 3326#3326: "server" directive is not allowed here in /etc/nginx/nginx.conf:11 2024/08/24 06:10:18 [notice] 3373#3373: signal process started 2024/08/24 06:19:53 [notice] 3445#3445: signal process started 2024/08/24 06:20:02 [error] 3446#3446: *12 SSL_do_handshake() failed (SSL: error:0A000438:SSL routines::tlsv1 alert internal error:SSL alert number 80) while SSL handshaking to upstream, client: 1xx.1x.5x.xx, server: know-cnu.wiki, request: "GET / HTTP/1.1", upstream: "https://[2400:61xx:0:dx::xa:a0x]:443/", host: "example.com" 2024/08/24 06:20:02 [error] 3446#3446: *12 SSL_do_handshake() failed (SSL: error:0A000438:SSL routines::tlsv1 alert internal error:SSL alert number 80) while SSL handshaking to upstream, client: 10x.13x.5x.18x, server: example.com, request: "GET / HTTP/1.1", upstream: "https://15x.8x.2xx.xx:443/", host: "example.com" 
    ]]>
    nginx 增加 http 块 就报证书错误,请问是什么原因,第一次见 tag:www.v2ex.com,2024-08-19:/t/1066197 2024-08-19T09:01:23Z 2024-08-19T10:18:39Z xinzi member/xinzi 域名已经处理 不增加 http 块,可以正常访问,证书正常,增加了 http 块就报证书错误,请教一下。全部都 docker 启动 我的 nginx 配置 如下

    worker_processes auto; # 自动设置为 CPU 核心数 worker_rlimit_nofile 100000; # 增加每个 worker 进程可以打开的文件数 events { worker_connections 4096; # 增加每个 worker 进程的最大连接数 multi_accept on; # 允许每个 worker 进程同时接受多个连接 } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; server { listen 80; server_name es.x.com.cn; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name es.x.com.cn; # SSL 证书和密钥配置 ssl_certificate /usr/share/nginx/html/ssl-qianduan/es.x.com.cn_bundle.pem; ssl_certificate_key /usr/share/nginx/html/ssl-qianduan/es.x.com.cn.key; # SSL 优化配置 ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; ssl_stapling on; ssl_stapling_verify on; location / { root /usr/share/nginx/html; # 路径改成自己的 dist 路径 index index.html index.htm; try_files $uri $uri/ /index.html; #解决刷新页面变成 404 问题的代码 } location /prod-api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://172.16.238.13:8089/; } } server { listen 80; server_name esb.x.com.cn; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name esb.x.com.cn; # SSL 证书和密钥配置 ssl_certificate /usr/share/nginx/html/ssl-houduan/esb.x.com.cn_bundle.pem; ssl_certificate_key /usr/share/nginx/html/ssl-houduan/esb.x.com.cn.key; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://172.16.238.13:8089/; } } # 阻止通过 IP 地址或未知的域名访问 server { listen 80 default_server; listen 443 default_server ssl; # SSL 证书和密钥配置 ssl_certificate /usr/share/nginx/html/ssl-houduan/esb.x.com.cn_bundle.pem; ssl_certificate_key /usr/share/nginx/html/ssl-houduan/esb.x.com.cn.key; server_name es.x.com.cn; return 444; # 返回一个非标准的状态码,通常用于阻止客户端的访问 } } 
    ]]>
    有台生产服务器, Nginx 每天都会因为不同原因 exit 一次,虽然配了自动重启,有没办法排查是什么原因?平均一天 1820 万请求 tag:www.v2ex.com,2024-08-15:/t/1065205 2024-08-15T05:19:10Z 2024-08-15T16:26:27Z drymonfidelia member/drymonfidelia 每天原因都不一样,这是今天的日志

    Aug 15 13:07:32 hostname nginx[3297853]: nginx: [emerg] host not found in upstream "backend.example.com" in /etc/nginx/sites-enabled/app1:25 Aug 15 13:07:32 hostname nginx[3297853]: nginx: configuration file /etc/nginx/nginx.conf test failed Aug 15 13:07:32 hostname systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Aug 15 13:07:32 hostname systemd[1]: nginx.service: Failed with result 'exit-code'. Aug 15 13:07:32 hostname systemd[1]: Failed to start A high performance web server and a reverse proxy server. 

    在这几秒前崩了没写日志,这个日志是刚自动重启后又崩了的。没改配置,10 秒后第三次自动重启就成功了。backend 在别的服务器上,内网 DNS 也一直正常

    ]]>
    openresty 怎么修改代理站的文件返回给客户端 tag:www.v2ex.com,2024-08-13:/t/1064581 2024-08-13T03:27:17Z 2024-08-13T07:05:55Z kaf member/kaf 源站有很多静态资源下载,openresty 作为网关加了鉴权,希望能解析特定的文本文件,把鉴权参数追加到文本文件的每一行,花了半天时间没搜索到什么资料。今天有看到可以直接通过 lua 脚本直接请求源站获取 body 之后修改后返回,openresty 主题人太少了,来这边希望有大佬指导下

    ]]>
    有啥平替 resend、ZeptoMail 的国内解决方案嘛? tag:www.v2ex.com,2024-08-11:/t/1064164 2024-08-11T11:02:25Z 2024-08-11T12:23:40Z EthZhang member/EthZhang 最近想在项目里加上邮件推送功能,重要的是想能够自定义发件域名的这种。像大厂提供的服务价格也忒黑了,海外的 API 服务我在国内服务器还 ping 不到,搞 nginx 反代也得单独再买台服务器,纠结中...

    ]]>
    求救:屏蔽爬虫试了 2 天,没成功 tag:www.v2ex.com,2024-08-04:/t/1062404 2024-08-04T09:16:28Z 2024-08-04T22:17:38Z cokyhe member/cokyhe 一台 10 年的老服务器,最近 bingbot 疯狂刷流量,用$http_user_agent 为啥屏蔽不了... nginx 日志里 N 多类似这样的记录:

    172.68.244.177 - - [04/Aug/2024:04:04:10 -0400] "GET /find-app/%E0%B8%AD%E0%B8%B2%E0%B8%8A%E0%B8%B5%E0%B8%9E%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%8A%E0%B8%B2%E0%B8%A7%E0%B8%AB%E0%B8%A7%E0%B8%B9%E0%B9%88%E0%B8%AB%E0%B8%A5%E0%B8%B4%E0%B8%87%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%81%E0%B8%9B%E0%B8%A5%E0%B8%B2%E3%80%90ta777.me%E3%80%91%E0%B8%AD%E0%B8%B2%E0%B8%8A%E0%B8%B5%E0%B8%9E%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%8A%E0%B8%B2%E0%B8%A7%E0%B8%AB%E0%B8%A7%E0%B8%B9%E0%B9%88%E0%B8%AB%E0%B8%A5%E0%B8%B4%E0%B8%87%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%81%E0%B8%9B%E0%B8%A5%E0%B8%B2%E3%80%90ta777.me%E3%80%91w7t?page=2 HTTP/1.1" 403 571 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/116.0.1938.76 Safari/537.36" 52.167.144.211 172.71.222.36 - - [04/Aug/2024:04:04:10 -0400] "GET /find-app/%E6%B9%96%E5%8D%97%E6%B0%B4%E5%88%A9%E6%B0%B4%E7%94%B5%E8%81%8C%E4%B8%9A%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2%E6%AF%95%E4%B8%9A%E8%AF%81%E6%A0%B7%E6%9C%AC%E5%9B%BE%E7%89%87%E2%8F%A9%E5%8A%9E%E7%90%86%E7%BD%91zhengjian.shop%E2%8F%AA-%E5%93%AA%E9%87%8C%E4%B9%B0%E6%B9%96%E5%8D%97%E6%B0%B4%E5%88%A9%E6%B0%B4%E7%94%B5%E8%81%8C%E4%B8%9A%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2%E6%AF%95%E4%B8%9A%E8%AF%81%E6%A0%B7%E6%9C%AC%E5%9B%BE%E7%89%87%F0%9F%8C%9F%E5%8A%9E%E8%AF%81%E7%BD%91zhengjian.shop%F0%9F%8C%9F-%E5%BC%A0%E5%AE%B6%E6%B8%AF%E6%B9%96%E5%8D%97%E6%B0%B4%E5%88%A9%E6%B0%B4%E7%94%B5%E8%81%8C%E4%B8%9A%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2%E6%AF%95%E4%B8%9A%E8%AF%81%E6%A0%B7%E6%9C%AC%E5%9B%BE%E7%89%87%E5%93%AA%E9%87%8C%E6%9C%89-%E5%93%AA%E9%87%8C%E5%8A%9E%E6%B9%96%E5%8D%97%E6%B0%B4%E5%88%A9%E6%B0%B4%E7%94%B5%E8%81%8C%E4%B8%9A%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2%E6%AF%95%E4%B8%9A%E8%AF%81%E6%A0%B7%E6%9C%AC%E5%9B%BE%E7%89%87Q5?page=3 HTTP/1.1" 403 571 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/116.0.1938.76 Safari/537.36" 52.167.144.211 

    以下是完整配置

    server { listen 80; listen 443 ssl; # ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; ## ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS; ## enable HSTS including subdomains add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; server_name domain.com www.domain.com; index index.html index.htm index.php; root /opt/htdocs/www.domain.com/public; #301 if ($host = 'domain.com') { rewrite ^/(.*)$ https://www.domain.com/$1 permanent; } #location ~ /find-app { if ($http_user_agent ~* "bingbot|AhrefsBot") { return 403; } #} location / { try_files $uri $uri/ /index.php?$query_string; } #申请 let’s Encrypt SSL 用 location ~ /.well-known { allow all; } if (!-e $request_filename) { } location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 15d; } access_log /data0/logs/domain.log access; } 
    ]]>
    [求助大佬] Nginx 反代多个网站出现串站问题 tag:www.v2ex.com,2024-07-28:/t/1060674 2024-07-28T08:51:12Z 2024-08-03T06:36:43Z Raymondx member/Raymondx 使用宝塔面板 8.2.0 、Nginx1.22.1 ,系统为 Ubuntu 20.04LTS

    操作:使用 Nginx 反代了三个网站

    网站一为:map.~.com → 81 端口,开启 https

    网站二为:frp.~.com → 7800 端口,未开启 https

    网站三为:r730test.~.com → 81 端口,未开启 https

    其中 81 端口为 frps 的 http 端口,map.~.com 和 r730test.~.com 都是部署在内网,用 frp 穿透出来的,7800 是 frp 的监控面板端口

    问题:现在访问 map.~.com 是正常的,但是访问 frp.~.com 和 r730test.~.com 会被跳转到 https://frp.~.com/和 https://r730test.~.com/ ,而且显示的是 map.~.com 的内容

    在添加 map.~.com 的反代之前都是正常的,添加了 map.~.com 的反代之后就出问题了

    Nginx 配置文件如下

    https://pastecode.io/s/uni4h5f6

    https://pastecode.io/s/80nxwxhx

    https://pastecode.io/s/0j74wdcn

    ]]>
    求 这种 NGINX 配置怎么写 tag:www.v2ex.com,2024-07-27:/t/1060477 2024-07-27T03:12:15Z 2024-07-27T05:03:23Z wzdc member/wzdc 如果重定向的链接包含 example.com (也就是域名为*.example.com )那么就缓存 10 小时,缓存键为 $scheme$request_method$host$request_uri$http_user_agent$http_authorization
    否则缓存 10 分钟,缓存键为 $scheme$request_method$host$request_uri$http_authorization

    这种 NGINX 配置怎么写? ]]>
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86