繁体   English   中英

nginx 连接到上游 https 时没有实时上游

[英]nginx no live upstreams while connecting to upstream https

我正在尝试将 api 请求代理到远程 api 服务器 ( https://api.domain.com ) 那是我的 nginx 配置

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        server_name dev.domain.com;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                proxy_pass http://127.0.0.1:8080;
        }

        location /api/ {
                proxy_pass https://api.domain.com;

        }

但我有错误

no live upstreams while connecting to upstream, client: x.x.x.x, server: dev.domain.com, request: "GET /api/current_ip HTTP/1.1", upstream: "https://api.domain.com/api/current_ip", host: "dev.domain.com", referrer: "https://dev.domain.com/api/current_ip"

我不明白我的配置中遗漏了什么。

您可以使用尝试请求URL http和代理通过https ,你需要添加SSL配置,当完成后,你hacve把location /api/location /

server {
        listen 80 default_server;       # to remove, You will need to setup SSL
        listen [::]:80 default_server;  # to remove, You will need to setup SSL

        listen 443 ssl;
        listen [::]:443 ssl;

        ssl_....
        ...

        server_name dev.domain.com;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        location /api/ {      ## Put this first
                proxy_pass https://api.domain.com;
        }

        location / {          ## Put this always at the end (is like a *wilcard)
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                proxy_pass http://127.0.0.1:8080;
        }
}

如果你想使用 TLS 反向代理某些东西,你也必须提供 TLS。

在某些时候,最好使用https为这个反向代理设置一个独立的配置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM