› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
aoscici2000
V2EX  ›  NGINX

Nginx 如何代理需要验证的地址 http://user:password@host/

  •  
  •   aoscici2000 · Dec 6, 2019 · 5496 views
    This topic created in 2523 days ago, the information mentioned may be changed or developed.
    server {
        listen       80;
        server_name  localhost;
    
        location /sk {
            proxy_pass       http://host:9000/xxx;
            proxy_set_header Authorization "Basic Z3Vlc3Q6Z3Vlc3Q";
        }
    

    返回: 400 Bad Request nginx 日志: No connection could be made because the target machine actively refused it

    直接写 proxy_pass http://user:password@host:9000/xxx; nginx 甚至无法启动

    代理这种需要验证的地址, 该怎么配置的?

    9 replies  •  2019-12-07 11:51:09 +08:00
    aoscici2000
    aoscici2000
    OP
    Dec 6, 2019
    2
    @znnspace 不是这个吧, 我要的是代理的目标网站设置了验证, 不是需要设置验证
    sleepm
    sleepm
    Dec 6, 2019
    3
    nginx 只管代理过去,响应回来验证还是要访客去输入的
    aoscici2000
    aoscici2000
    OP
    Dec 6, 2019
    4
    @sleepm 那直接提供密码不能由 nginx 去做验证吗, 假设我要用消息队列的话, nginx 不能直接把请求送进队列也有点说不过去啊?
    Vegetable
    Vegetable
    Dec 6, 2019
    5
    确定不是 token 写错了?
    rubycedar
    rubycedar
    Dec 6, 2019
    6
    看上游的 log 啊
    aoscici2000
    aoscici2000
    OP
    Dec 6, 2019 via iPhone
    7
    @Vegetable 没写错,故意写个错的反而能正常返回提示信息...
    sleepm
    sleepm
    Dec 6, 2019 via Android
    8
    @aoscici2000 那你请求 nginx 的时候带上认证的头不就行了,nginx 一块转发了
    mikeguan
    mikeguan
    Dec 7, 2019 via Android
    9
    搜索的是需要 user:passwd 进行 base64,看你的配置也不像是 base64
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1293 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 21:08 · PVG 05:08 · LAX 13:08 · JFK 16:08
    ♥ Do have faith in what you're doing.