1
CnpPt 2023-08-11 16:45:15 +08:00
按照你的说法,问题不在/上,而且你可能不清楚加不加/的区别,第二天是哪个 location 无法使用?如果是第一个 location /,proxy_pass 反代的域名是不是 DDNS 域名 经常变 IP ?
|
2
yuanyuandeqiu OP |
3
maclanelf134 2023-08-11 17:00:35 +08:00
@yuanyuandeqiu 有区别,可以去查查,不清楚你那边的具体是啥业务场景,可以在提供细一点,是反代域名有问题,还是反代下面那个 ip 出问题
|
4
yulgang 2023-08-11 17:00:41 +08:00
后端服务器处理路径时 /api 和 /api/ 这两种情况有不同的行为?隔天不好用感觉像是浏览器缓存的问题
|
5
skiy 2023-08-11 17:03:08 +08:00
你看看 8848 端口的日志,看请求的 URI 是什么,对比一下。
|
6
yuanyuandeqiu OP @skiy 看日志的话 URI 是一样的
@yulgang 之前的话是两个都不行,报 404 ,然后我开了个无痕模式就可以了,再然后就出现两个地址轮流出问题的情况,不知道和缓存有没有关系 @maclanelf134 其他人的都没问题,应该是我的问题,一样的配置就我的会这样,不知道和 nginx 版本有没有关系 |
7
yulgang 2023-08-11 17:23:22 +08:00
|
8
yuanyuandeqiu OP nginx: the configuration file D:\programe\nginx-1.24.0/conf/nginx.conf syntax is ok
nginx: configuration file D:\programe\nginx-1.24.0/conf/nginx.conf test is successful # configuration file D:\programe\nginx-1.24.0/conf/nginx.conf: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; gzip on; gzip_disable "msie6"; server { listen 80; server_name localhost; location /scoreserv { proxy_pass http://127.0.0.1:8080; } location / { proxy_pass https://example1.com/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 82; location / { proxy_pass https://example2.com; } location /api { proxy_pass http://127.0.0.1:8848; } } } |
9
yuanyuandeqiu OP # configuration file D:\programe\nginx-1.24.0/conf/mime.types:
types { text/html html htm shtml; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/javascript js; application/atom+xml atom; application/rss+xml rss; text/mathml mml; text/plain txt; text/vnd.sun.j2me.app-descriptor jad; text/vnd.wap.wml wml; text/x-component htc; image/avif avif; image/png png; image/svg+xml svg svgz; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/webp webp; image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; font/woff woff; font/woff2 woff2; application/java-archive jar war ear; application/json json; application/mac-binhex40 hqx; application/msword doc; application/pdf pdf; application/postscript ps eps ai; application/rtf rtf; application/vnd.apple.mpegurl m3u8; application/vnd.google-earth.kml+xml kml; application/vnd.google-earth.kmz kmz; application/vnd.ms-excel xls; application/vnd.ms-fontobject eot; application/vnd.ms-powerpoint ppt; application/vnd.oasis.opendocument.graphics odg; application/vnd.oasis.opendocument.presentation odp; application/vnd.oasis.opendocument.spreadsheet ods; application/vnd.oasis.opendocument.text odt; application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; application/vnd.wap.wmlc wmlc; application/wasm wasm; application/x-7z-compressed 7z; application/x-cocoa cco; application/x-java-archive-diff jardiff; application/x-java-jnlp-file jnlp; application/x-makeself run; application/x-perl pl pm; application/x-pilot prc pdb; application/x-rar-compressed rar; application/x-redhat-package-manager rpm; application/x-sea sea; application/x-shockwave-flash swf; application/x-stuffit sit; application/x-tcl tcl tk; application/x-x509-ca-cert der pem crt; application/x-xpinstall xpi; application/xhtml+xml xhtml; application/xspf+xml xspf; application/zip zip; application/octet-stream bin exe dll; application/octet-stream deb; application/octet-stream dmg; application/octet-stream iso img; application/octet-stream msi msp msm; audio/midi mid midi kar; audio/mpeg mp3; audio/ogg ogg; audio/x-m4a m4a; audio/x-realaudio ra; video/3gpp 3gpp 3gp; video/mp2t ts; video/mp4 mp4; video/mpeg mpeg mpg; video/quicktime mov; video/webm webm; video/x-flv flv; video/x-m4v m4v; video/x-mng mng; video/x-ms-asf asx asf; video/x-ms-wmv wmv; video/x-msvideo avi; } |
10
yuanyuandeqiu OP @yulgang nginx -T 感觉没什么问题
|
11
julyclyde 2023-08-11 19:45:38 +08:00
无论加还是不加,都不可能出现“第二天就不能用”的情况
应该是从头到尾行为一致的 |
12
my3157 2023-08-11 19:47:40 +08:00 via Android
域名最好加个 resolver
|
13
mmdsun 2023-08-11 19:50:40 +08:00 via iPhone
location /api/和 location /api 、proxy_pass 结尾加不加/有区别的。会决定是否吧请求的路径中的/api 转发到后端 proxy_pass 。地址。
你这可能有缓存吧?或者多个 nginx 进程没杀死,好像以前 Windows nginx 会有这个问题,taskkill /f /t 批量结束下 |
14
yulgang 2023-08-14 09:44:26 +08:00
@yuanyuandeqiu #10
不知道你有没有解决 试一试禁用缓存看看: location /api { proxy_pass http://127.0.0.1:8848; proxy_cache_bypass $http_cache_control; add_header Cache-Control 'no-cache'; } 或者 location /api { proxy_pass http://127.0.0.1:8848; proxy_cache_valid 200 302 10m; # 设置 200 和 302 响应的缓存时间为 10 分钟 proxy_cache_bypass $http_cache_control; add_header Cache-Control 'no-cache'; } |
15
gotosre 2023-08-16 19:27:01 +08:00 via iPhone
带不带斜杠也就是做不做 prefix trim 的区别,,,至于玄学问题么,大概率是变配错觉
|
16
yuanyuandeqiu OP @yulgang 已经解决了,现在可以用固定的配置访问了
|