目前分類:Nginx (3)

瀏覽方式: 標題列表 簡短摘要

Nginx除代理外也具有Load balance功能,透過upstream來設定,算是非常簡易的設定方式

http {
    upstream myapp {
        server srv1.example.com;
        server srv2.example.com;
        server srv3.example.com;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://myapp;
        }
    }
}

 

文章標籤

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

繼上次某方程式不支援HTTPS後,這次又出了不支援轉址的情況,所以只好再請Nginx代為內部處理轉址而不是將轉址資訊返回給原程式

server {
    listen 80;
    server_name _;
    location /psn/ {
        proxy_pass http://127.0.0.1:90;

        proxy_intercept_errors on;           //開啟攔截http error的功能
        error_page 301 302 301 = @redirect;  //攔截指定要的代號並丟給@redirect處理
    }

    location / {
        return 301 https://account.sp-int.ac.playstation.net/;
    }

    location @handle_redirect {
        set $saved_redirect_location '$upstream_http_location'; //將30x返回的網址紀錄
        proxy_pass $saved_redirect_location;                    //重新再proxy_pass一次
    }
}

模擬了一個轉址的url在localhost,localhost/psn/負責處理發生轉址的部分

文章標籤

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

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

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

文章標籤

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