2016-07-28 28 views
0

我們已經部署和運行WSO2 API Manager 1.10.0。雖然我們正在試圖弄清楚是否有可能擁有多個子域名。WSO2 APIM:不同上下文的子域名

例如:

store.domain.com 
publisher.domain.com 
carbon.domain.com 

這是在所有可能的?我們已經看到這個https://docs.wso2.com/display/Carbon442/Adding+a+Custom+Proxy+Path,但是這是針對不同的應用程序,我們只想用API管理器來做到這一點。

在API管理器之前,我們使用帶有反向代理的nginx。下面,你可以從nginx中找到一個片段來幫助理解問題。

server { 
    listen 80; 
    server_name store.domain.com; 
    return 301 https://$server_name$request_uri; 
} 

server { 
    listen 443 ssl; 
    ssl on; 
    ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH";#:AES128+EDH"; 
    ssl_protocols TLSv1.1 TLSv1.2; 
    ssl_prefer_server_ciphers on; 
    add_header Strict-Transport-Security "max-age=63072000"; 

    server_name store.domain.com; 

    ssl_certificate /etc/nginx/ssl/domain.com/self-ssl.crt; 
    ssl_certificate_key /etc/nginx/ssl/domain.com/self-ssl.key; 

    access_log /var/log/nginx/store.log; 
    underscores_in_headers on; 

    location/{ 
     proxy_pass http://wso2server:9443/store/; 
     proxy_redirect off; 
     proxy_set_header Host $host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-Server $host; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    } 
} 

在嘗試與HTTP訪問(爲存儲上下文)一切工作正常,但只要我們關掉這個到HTTPS失敗與nginx的upstream prematurely closed connection while reading response header from upstream但是下面的錯誤,我們看不到任何的API管理日誌。

在此先感謝!

祝好運

+1

你有HTTP,而不是在「親HTTPS xy_pass http:// wso2server:9443/store /「,你可以檢查它。在APIM默認9443是https – Jenananthan

+0

謝謝@Jenananthan我們已經糾正了這一點。雖然還沒有運氣。看起來,APIM後端正在將URL重寫爲'wso2server',它是'carbon.xml'文件中的HostName。 – afgd

+0

你是否還在從上游讀取響應頭時出現「上游過早關閉連接」錯誤?你有沒有通過這個博客http://sanjeewamalalgoda.blogspot.com/2014/12/configure-wso2-api-manager-with-reverse.html? – Jenananthan

回答

0

您可以通過以下方法之一解決您的問題。

  1. 將proxy_redirect配置添加到Nginx。所以nginx會將所有的URL重寫爲正確的URL。請參考下面的配置段。
proxy_redirect http://wso2server/ http://store.domain.com/; 
  • 還可以實現通過在API管理器存儲添加反向代理的配置是相同的。要做到這一點打開 「庫/部署/服務器/ jaggeryapps /存儲/網站/ conf目錄/ site.json」,看看下面的配置部分
  • 「反向代理」:{ 「已啓用」:假的,/ /值true,false,「auto」 - 將查找X-Forwarded- *標頭 「host」:「sample.proxydomain.com」,//如果反向代理沒有域名,則使用IP 「context」: 「」 // 「regContext」: 「」 //使用僅用於註冊表 }不同的路徑,