Configuring reverse proxy by Nginx |
Feedback |
Start Nginx
- Unzip nginx to the specified directory
- In the root directory of nginx, start nginx
by the following command:
start nginx
Exit nginx:
nginx –s quit
- check whether to start nginx normally with
two ways:
- Open Task Manager to see whether the nginx
process is started.
- Access http://127.0.0.1 or http://localhost,
if it shows“Welcome to nginx!”, it means nginx is started normally.
Configure Nginx
Open nginx installation directory\conf\nginx.conf file,
modify the server node under http node:
server {
listen
192.168.120.42:8000;
server_name
www.myiserver.com;
location
/ iserver{
proxy_pass
http://192.168.112.217:8090/iserver;
#proxy_set_header
Host $host:8000;
proxy_set_header
ProxyHost $host:8000; }
}
- Listen: proxy service listening port, 80 by
default, it is recommended not to use the default one.
- server_name: proxy server name, usually uses
the domain of the proxy server.
- proxy_pass: GIS service address to be forwarded,
can be IP or domain.
- proxy_set_header: forward request head, only
needed to set the service address. If not set, when accessing reverse
proxy service, the page will be linked to the original GIS server
not the current one. Set it by Host or ProxyHost:
- Host: parameter provided by nginx, such as:
proxy_set_header Host $host:8000. This setting may cause other services
in the current reverse proxy server unavailable.
- ProxyHost: SuperMap customized parameter, such
as: proxy_set_header ProxyHost $host:8000. It's recommended to use
ProxyHost to set the service address in the request head.
Save above settings, restart
nginx to enable it. Restart command:
nginx -s reload
If needed to configure multiple iServer reverse proxies,
you can configure multiple server nodes in nginx.conf file.
Access service
http://192.168.120.42:8000/iserver
You also can map 192.168.120.42 for the domain name,
just add the followings in C:\Windows\System32\drivers\etc\hosts:
192.168.120.42 www.myiserver.com
Then you can use this address: http://www.myiserver.com:8000/iserver.