大佬们求助 nginx 配置 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yeccc
V2EX    NGINX

大佬们求助 nginx 配置

  •  
  •   yeccc 2023-06-22 14:43:59 +08:00 2043 次点击
    这是一个创建于 841 天前的主题,其中的信息可能已经有所发展或是发生改变。

    公司业务每次更新测试代码都需要登陆到跳板机,在跳板机更新代码打包然后在远程内网的服务器手动将包放上去发布,跳板机器是可以访问代码仓库云效的, 所以在跳板机搞了一个 nginx 来做正向代理处理内网服务器的请求来实现代码更新包更新之类的操作,但是不知道是不是配置的问题一直请求一直 405 ,还有更新 mavne 依赖的时候也会 timeou t 前端 node 依赖也是安装不了的 image.png

    image.png

    ,http 是可以正常拉取代码的但是 https 就不行,求大佬帮忙看看 下面是 nginx 配置(添加了 ngx_http_proxy_connect 模块)

    worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { resolver 114.114.114.114; listen 880 default_server; location / { proxy_pass http://$host$request_uri; proxy_set_header HOST $host; proxy_buffers 256 4k; proxy_max_temp_file_size 0k; proxy_connect_timeout 30; proxy_send_timeout 60; proxy_read_timeout 60; proxy_next_upstream error timeout invalid_header http_502; } } server { listen 443; # dns resolver used by forward proxying resolver 8.8.8.8; # forward proxy for CONNECT request proxy_connect; proxy_connect_allow 443; proxy_connect_connect_timeout 10s; proxy_connect_read_timeout 10s; proxy_connect_send_timeout 10s; # forward proxy for non-CONNECT request location / { proxy_set_header Host $host; 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; } } } 
    7 条回复    2023-06-24 15:32:55 +08:00
    ryd994
        1
    ryd994  
       2023-06-22 15:32:07 +08:00 via Android
    你不需要 listen 443

    proxy_connect 相关内容放到上面 880 的配置一起

    代理 https 时,客户端会明文连接到代理服务器,要求 connect 某网站。代理服务器会通过明文通道直接转发 TLS 加密后的密文。TLS 的安全性是从后端到客户端,端到端加密。代理服务器不解密。
    akira
        2
    akira  
       2023-06-22 19:28:20 +08:00
    有点奇怪的用法。。
    yeccc
        3
    yeccc  
    OP
       2023-06-22 21:19:33 +08:00
    @akira 为了不手动打包不得已
    yeccc
        4
    yeccc  
    OP
       2023-06-22 21:20:16 +08:00
    @ryd994 哦哦,谢谢大佬我去试试
    yeccc
        5
    yeccc  
    OP
       2023-06-22 21:52:14 +08:00
    @ryd994 大佬我按照你说的将 proxy_connect 与 880 的配置在一起,还是一样的问题
    http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
    resolver 8.8.8.8; #指定 DNS 服务器 IP 地址
    listen 880 default_server;

    proxy_connect;
    proxy_connect_allow 443;
    proxy_connect_connect_timeout 10s;
    proxy_connect_read_timeout 10s;
    proxy_connect_send_timeout 10s;

    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_buffers 256 4k;
    proxy_max_temp_file_size 0k;
    proxy_connect_timeout 30;
    proxy_send_timeout 60;
    proxy_read_timeout 60;
    proxy_next_upstream error timeout invalid_header http_502;
    error_page 405 =200 http://$host$request_uri;
    }
    }
    julyclyde
        6
    julyclyde  
       2023-06-24 12:47:06 +08:00
    405 是 method not allowed
    你的代理服务器环境变量咋设置的?是不是匹配到另一个 server{}去了?
    看看 nginx 的 error_log 里咋写的
    yeccc
        7
    yeccc  
    OP
       2023-06-24 15:32:55 +08:00
    @julyclyde 改了源码,重新编译了一下可以了谢谢
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1045 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 18:25 PVG 02:25 LAX 11:25 JFK 14:25
    Do have faith in what you're doing.
    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