簡體   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