...
This feature is particularly useful when multiple WSO2 products (fronted by a proxy server) are hosted under the same domain name. By adding a custom proxy path you can host all products under a single domain and assign proxy paths for each product separately .
Expand |
---|
title | Click here to see how to add custom proxy paths... |
---|
|
Note |
---|
| Follow steps 1 to 8 in the Administration guide, to install Nginx if you haven't done so already. |
The sample usecase to route requests is shown below. Image Added
Warning |
---|
Some of the Nginx configuration syntaxes may slightly vary based on the Nginx version you use. The configurations below are tested with version 1.15.0. |
Open the /etc/nginx/sites-enabled/wso2 file and enter the following configurations.
Code Block |
---|
server {
listen 443 ssl;
ssl_certificate nginx.crt;
ssl_certificate_key nginx.key;
location ~ ^/apimanager/publisher/(.*)registry/(.*)$ {
index index.html;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:9443/$1registry/$2;
}
location /apimanager/publisher {
index index.html;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://localhost:9443/publisher;
proxy_redirect https://localhost:9443/publisher https://localhost/apimanager/publisher;
proxy_cookie_path /publisher /apimanager/publisher;
}
location ~ ^/apimanager/store/(.*)registry/(.*)$ {
index index.html;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:9443/$1registry/$2;
}
location /apimanager/store {
index index.html;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://localhost:9443/store;
proxy_redirect https://localhost:9443/store https://localhost/apimanager/store;
proxy_cookie_path /store /apimanager/store;
}
location /apimanager/admin {
index index.html;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://localhost:9443/admin;
proxy_redirect https://localhost:9443/admin https://localhost/apimanager/admin;
proxy_cookie_path /admin /apimanager/admin;
}
} |
Configure the reverseProxy for the following. Localtabgroup |
---|
Localtab |
---|
| Open the <API-M_HOME>/repository/deployment/server/jaggeryapps/publisher/site/conf/site.json file and do the following configurations. Code Block |
---|
"reverseProxy" : {
"enabled" : true, // values true , false , "auto" - will look for X-Forwarded-* headers
"host" : "localhost", // If reverse proxy do not have a domain name use IP
"context":"/apimanager/publisher",
//"regContext":"" // Use only if different path is used for registry
}, |
|
Localtab |
---|
| Open the <API-M_HOME>/repository/deployment/server/jaggeryapps/store/site/conf/site.json file and do the following configurations. Code Block |
---|
"reverseProxy" : {
"enabled" : true, // values true , false , "auto" - will look for X-Forwarded-* headers
"host" : "localhost", // If reverse proxy do not have a domain name use IP
"context":"/apimanager/store",
//"regContext":"" // Use only if different path is used for registry
}, |
|
Localtab |
---|
| Open the <API-M_HOME>/repository/deployment/server/jaggeryapps/admin/site/conf/site.json file and do the following configurations. Code Block |
---|
"reverseProxy": {
"enabled": true,
// values true , false , "auto" - will look for X-Forwarded-* headers
"host": "localhost",
// If reverse proxy do not have a domain name use IP
"context": "/apimanager/admin"
//"regContext":"" // Use only if different path is used for registry
}, |
|
|
Open the <API-M_HOME>/repository/conf/api-manager.xml file. Set the URL as shown below, to get the View in Store link on API overview tab in the API Publisher. Code Block |
---|
<APIStore>
...................
<URL>https://localhost/apimanager/store</URL>
...................
</APIStore> |
You have now added custom proxy paths for the API Publisher, API Store, and Admin Portal. |
For instructions on configuring custom proxy paths, see Adding a Custom Proxy Path in the WSO2 Administration Guide.
...