Combined use of service proxy and Nginx rerverse proxy

Feedback


First, you need to do perform proxy configuration for the registered service. For specifics, please refer to Proxy Configuration for Registered Services.

Next, you need to configure the Nginx reverse proxy server.

Start Nginx

Here we take Windows as an example:

  1. Unzip nginx to the specified directory
  2. In the root directory of nginx, start nginx by the following command:

start nginx

Exit nginx:

nginx –s quit

Configure Nginx

Open [nginx installation directory]\conf\nginx.conf file, modify the server node under http node:

server {

        listen       80;

        server_name  www.myiportal.com;

        location /{

            proxy_pass   http://192.168.120.52:8090/;

            proxy_set_header Host $host:80;

            proxy_set_header X-Read-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

        location ~*/iserver/services/ {

            proxy_pass   http://192.168.120.52:8195;

            proxy_set_header Host $host:80;

            proxy_set_header X-Read-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

Save the changes above and restart the Nginx to take effect. The reboot command is as follows:

nginx -s reload

If you need to configure the reverse proxy of multi-iPortal, or if you need to configure iServer reverse proxy at the same time, you can configure multiple server nodes in nginx.conf.

Note: If the iServer service went through iPortal service proxy after Nginx proxy, it is recommend the above host parameter be set to: Host $http_host to ensure the service runs normally.

If you need to match multiple service addresses, you can configure multiple location in nginx.conf.

Configure the maximum number of single file bytes allowed by Nginx from the client

The maximum number of single file bytes allowed by Nginx from the client is 1m by default. If the user accesses iPortal after Nginx proxy, and upload large data files to the portal, 1m is far from enough at this time. It is recommended that you amend the parameter to 1024m, that is, allow a maximum of 1024m data files. You can also configure according to specific business requirements as follows:

Open the [Nginx installation path]\conf\nginx. conf file and add the following line of code under the HTTP node:

client_max_body_size 1024m;

Configure iPortal

To implement the reverse proxy of service address after service proxy registration, and hide the port of the proxy service, you need to configure the iportal. xml file under [SuperMap iPortal installation directory]\webapps\iportal\web-inf folder. Add a <proxyServerRootUrl> node in the <serviceProxy> node of the iportal.xml configuration file to set the root address of the reverse proxy service. Because there are two modes of display for Host in the proxy service address: domain name and IP, <proxyServerRootUrl> node can be configured in two ways:

Method 1: Doman format

<serviceProxy>

    <enable>true</enable>  

    <port>8195</port>  

    <proxyServerRootUrl>http://www.myiportal.com[:port]</proxyServerRootUrl>  

    <httpConnPoolInfo>

      <maxTotal>20</maxTotal>  

      <defaultMaxPerRoute>2</defaultMaxPerRoute>

    </httpConnPoolInfo>

  </serviceProxy>

Method 2: IP format. This configuration will dynamically display IP addresses based on the user's current network environment in the proxy service address.

<serviceProxy>

    <enable>true</enable>  

    <port>8195</port>  

    <proxyServerRootUrl>http://{ProxyHost}[:port]</proxyServerRootUrl>  

    <httpConnPoolInfo>

      <maxTotal>20</maxTotal>  

      <defaultMaxPerRoute>2</defaultMaxPerRoute>

    </httpConnPoolInfo>

  </serviceProxy>

After configuration, restart iPortal.

Note: For the two above methods, [:port] represents the port. You can enter the service listener port after proxy, or you can leave it empty. The default port number is 80.

Access services

You can access the service address after the reverse proxy, for example: http://192.168.120.40, where the default port 80 can be hidden. The service root address after service proxy registration will become: http://192.168.120.40, which also hides the service proxy port "8195".

In a real business application, if you want to access iPortal and services using the domain name, you will need to bind the IP of the Nginx reverse proxy to the domain name and then access the reverse proxy service via that domain name, http://www.myiportal.com. At the same time, the service root address after service proxy registration will also become: http://www.myiportal.com.