close

因為某方寫的C++Server只支援HTTP並沒支援到HTTPS,因此要打API給PSN時就悲劇了....

只好多透過一手Nginx轉發來完成原本的需求

server {
    listen 80 ;
    listen [::]:80 ;
    server_name _;

    location  /psn/ {
             rewrite ^/psn/(.*) /$1 break;  //移除掉多餘的/psn目錄
             proxy_pass https://$host;      //轉發給原對象
    }

傳遞過程是A(HTTP) -> Nginx(HTTPS) -> B -> Nginx -> A

 

與rewrite或return 301告知轉址的作法結果不同

server {
    listen 80;
    listen [::]:80 ;
    server_name _; 

    return 301 https://$host$request_uri;   //告知轉址
}

傳遞過程是A(HTTP) -> Nginx -> A(HTTPS) -> B -> A

 

因為A沒支援HTTPS所以依然無法運作。

 

 

arrow
arrow
    文章標籤
    nginx http https
    全站熱搜

    不來嗯 發表在 痞客邦 留言(0) 人氣()