小编alu*_*ter的帖子

Nginx 代理/上游重定向使用错误的端口和协议

我使用 NGINX 服务器作为其他一些 NGINX 服务器的 ssl 代理。不幸的是,如果请求被上游服务器重定向,则位置字段包含错误的目标端口。

curl -v "https://example.com/site":

> GET /site HTTP/2
> Host: example.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 301 
< server: nginx
< date: Sun, 18 Mar 2018 20:01:44 GMT
< content-type: text/html
< content-length: 178
< location: http://example.com:9101/site/
< strict-transport-security: max-age=15768000; includeSubDomains
Run Code Online (Sandbox Code Playgroud)

NGINX 代理:

# Proxy: example.com
####################

server {
  listen 0.0.0.0:80;
  listen [::]:80;
  server_name example.com;
  root /srv/www/_empty;
  location / { return 301 https://example.com$request_uri; …
Run Code Online (Sandbox Code Playgroud)

rewrite nginx proxy https

5
推荐指数
1
解决办法
7722
查看次数

标签 统计

https ×1

nginx ×1

proxy ×1

rewrite ×1