[英]NGINX proxy_pass same protocol (http/https)
我的NGINX配置文件中有一節使用proxy_pass
將API流量重定向到上游服務器。 我在一個server
塊中有location
s,它同時提供http和https請求:
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name mysite.local; # Valid TLD in production
然后我有location
塊來定義我的API網關:
location /api/v1/json {
# Various proxy config directives
proxy_pass http://upstream;
我的問題是:是否可以刪除http://
並根據協議將請求傳遞給我的上游服務器而不拆分我的server
塊? 像HTML / JavaScript //mysite.local
請求之類的東西。
你可以使用$scheme
變量:
location /api/v1/json {
# Various proxy config directives
proxy_pass $scheme://your-host
}
來自文檔 :
$scheme
request scheme, "http" or "https"
然后,它將使用與原始請求相同的協議。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.