欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

nginx proxy_redirect的作用及說明

 更新時間:2024年06月05日 08:59:26   作者:hkNaruto  
這篇文章主要介紹了nginx proxy_redirect的作用及說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

準(zhǔn)備環(huán)境

springboot /redirect controller

curl http://localhost:10080/redirect -vv
*   Trying ::1:10080...
* Connected to localhost (::1) port 10080 (#0)
> GET /redirect HTTP/1.1
> Host: localhost:10080
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Location: http://localhost:10080/ip
< Content-Length: 0
< Date: Wed, 26 May 2021 05:55:45 GMT
< 
* Connection #0 to host localhost left intact

1. 默認(rèn)配置

即proxy_redirect default;

location / {
                proxy_pass http://localhost:10080/;
        }

效果

curl -vv http://localhost/redirect
*   Trying ::1:80...
* connect to ::1 port 80 failed: 拒絕連接
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /redirect HTTP/1.1
> Host: localhost
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 
< Server: nginx/1.19.3
< Date: Wed, 26 May 2021 05:57:02 GMT
< Content-Length: 0
< Location: http://localhost/ip
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< 
* Connection #0 to host localhost left intact

2. proxy_redirect default;

location / {
                proxy_pass http://localhost:10080/;
                proxy_redirect default;
        }

注意,proxy_redirect default必須在proxy_pass下方配置

效果

curl -vv http://localhost/redirect
*   Trying ::1:80...
* connect to ::1 port 80 failed: 拒絕連接
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /redirect HTTP/1.1
> Host: localhost
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 
< Server: nginx/1.19.3
< Date: Wed, 26 May 2021 06:02:20 GMT
< Content-Length: 0
< Location: http://localhost/ip
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< 
* Connection #0 to host localhost left intact

與方案1等同

3. proxy_redirect off;

location / {
                proxy_pass http://localhost:10080/;
                proxy_redirect off;
        }

效果

curl http://localhost:10080/redirect -vv
*   Trying ::1:10080...
* Connected to localhost (::1) port 10080 (#0)
> GET /redirect HTTP/1.1
> Host: localhost:10080
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Location: http://localhost:10080/ip
< Content-Length: 0
< Date: Wed, 26 May 2021 06:03:34 GMT
< 
* Connection #0 to host localhost left intact

可以看到,302響應(yīng)的是內(nèi)部地址。

總結(jié)

常規(guī)部署情況下,不需要特別配置proxy_redirect或者配置proxy_redirect default即可。

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論