求助, nginx 做正向代理出现 502 bad gateway - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
yeccc
V2EX    程序员

求助, nginx 做正向代理出现 502 bad gateway

  •  
  •   yeccc 2023-06-23 17:03:38 +08:00 1780 次点击
    这是一个创建于 890 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 nginx 做内网服务器的正向代理,更新 npm 依赖的时候会出现 502

    nginx 配置

    worker_processes auto; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; log_format ty_proxy_log_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '"$upstream_addr"'; gzip on; gzip_http_version 1.0; gzip_comp_level 6; gzip_proxied any; #gzip_min_length 500; gzip_buffers 16 8k; gzip_types text/plain application/x-Javascript text/css application/xml text/Javascript application/x-httpd-php application/Javascript application/json; server { charset utf-8; resolver 114.114.114.114; listen 880 default_server; proxy_connect; proxy_connect_allow all; proxy_connect_connect_timeout 60s; proxy_connect_read_timeout 60s; proxy_connect_send_timeout 60s; access_log logs/proxy_access.log ty_proxy_log_format; location / { proxy_pass $scheme://$host$request_uri; 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_redirect off; proxy_set_header X-NginX-Proxy true; proxy_ssl_server_name on; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_send_timeout 600; proxy_buffer_size 64k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_next_upstream error timeout invalid_header http_502; } error_page 405 =200 @405; location @405 { proxy_method GET; proxy_pass $scheme://$host/$request_uri; } } server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 

    nginx 日志

    access 日志 [23/Jun/2023:17:00:29 +0800] "CONNECT registry.npmmirror.com:443 HTTP/1.1" 502 157 "-" "-" "-" "-" error 日志 2023/06/23 17:00:29 [error] 26952#45320: *3314 proxy_connect: upstream connect failed (10051: A socket operation was attempted to an unreachable network) while connecting to upstream, client: 172.30.30.80, server: , request: "CONNECT registry.npmmirror.com:443 HTTP/1.1", host: "registry.npmmirror.com" 
    rekulas
        1
    rekulas  
       2023-06-23 17:33:51 +08:00
    感觉是 registry.npmmirror.com 443 连不上 服务器网络问题
    yeccc
        2
    yeccc  
    OP
       2023-06-23 17:39:55 +08:00
    @rekulas 没次会有一两个依赖出现 502 其他都正常
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     872 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 22:53 PVG 06:53 LAX 14:53 JFK 17:53
    Do have faith in what you're doing.
    ubao msn 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