Tutorial 4: Hosting Web APIs in Kestrel

Kestrel is the default Web server used for ASP.NET Core applications (such as PowerServer Web APIs). When a new ASP.NET Core project is created, it includes the Kestrel Web server by default. Kestrel is an open-source, cross-platform and light-weight Web server; it provides better request processing performance to ASP.NET Core applications, but does not have advanced features of Web servers like IIS, Nginx, Apache etc. Therefore, to use Kestrel to host the PowerServer Web APIs, a reverse proxy server (such as IIS, Nginx, or Apache) is usually recommended.

Kestrel serves the dynamic content (such as data processing tasks) from the PowerServer Web APIs.

The reverse proxy server serves the static content, caching requests, compressing requests, and HTTPS termination from the Web server. The reverse proxy server may reside on a dedicated machine or may be deployed alongside a Web server.

The Web server, reverse proxy server, and Kestrel server can reside in the same or different machine.


About PowerServer Web API and Kestrel

As aforementioned, Kestrel is by default used by the ASP.NET Core project templates, therefore it is automatically included in the PowerServer Web APIs, and there is no need to install or configure Kestrel.

The host and port where the Kestrel server listens are configured in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.

    "ServerAPIs": {
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "ischecked": "true",
      "applicationUrl": "HTTP://0.0.0.0:6000"
    }

In the Program.cs file under the ServerAPIs project, the ConfigureWebHostDefaults method calls ConfigureKestrel:

            hostBuilder.ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.ConfigureKestrel(serverOptions =>
                {                    
                    serverOptions.Limits.MaxRequestBodySize = Int32.MaxValue;
                });

                webBuilder.UseStartup<Startup>();
            });

Configuring Apache reverse proxy server (Windows)

Preparations

In this tutorial, we will learn how to set up Apache on Windows and use it as the reverse proxy server to redirect requests to the PowerServer Web APIs running on the Kestrel server.

The Apache reverse proxy server can be set up on the same or different server from the PowerServer Web APIs and Kestrel. In this tutorial, the same server will be used.

In this tutorial, we will configure and use the following server environment and URLs. Be careful to use the correct port number and make sure the port is not occupied by any other program.


Step 1: Set up the server with the following OS and software (install the software in the order listed).

  • Windows Server 2019 (64-bit)

  • Visual C++ Redistributable

  • Apache HTTP Server 2.4.47

    The section Installing Apache HTTP Server has detailed installation instructions.

Step 2: Make sure the server can connect to the NuGet site: https://www.nuget.org (for installing PowerServer NuGet packages) and the following Appeon sites: https://apips.appeon.com, https://apipsoa.appeon.com, https://apipsinfo.appeon.com, and https://api.appeon.com (for validating the PowerServer license).

Step 3: Configure Windows Defender Firewall on the server to allow the port number (80 and 8080 in this tutorial or any port number you choose). The section "Configuring Windows Defender Firewall" has detailed instructions.

Configuring Apache

This section is to configure Apache as a reverse proxy server in a Windows machine.

Step 1: Go to the ..\Apache24\conf folder and open the httpd.conf file in a text editor.

Step 2: Add the following scripts to the end of the httpd.conf file.

This is to configure Apache as a reverse proxy server which will redirect requests made to the URL: http://172.16.100.35:8080/ to the PowerServer Web APIs running on Kestrel at http://172.16.100.35:6000/.

# Listen on port 8080 or any port you choose. Make sure it is not used by any other program. 
<VirtualHost *:8080> 
 ProxyPreserveHost On
 ErrorLog logs\ps-error.log   
 CustomLog logs\ps-access.log common  
 # Pass all requests received at the root http://172.16.100.35/8080 to http://172.16.100.35:6000/ (PowerServer Web APIs running on Kestrel server) and in reverse.
 ProxyPass / http://172.16.100.35:6000/ 
 ProxyPassReverse / http://172.16.100.35:6000/
</VirtualHost>

Step 3: Locate the following line in the httpd.conf file and specify the port number: 80 (or any port you choose) is used to access the static Web files on the Apache HTTP server, 8080 is used to access Web APIs (according to the reverse proxy setting in step 2, requests made to 8080 will be forwarded to 6000.)

Change

Listen 80

To

Listen 80
Listen 8080

Tip: In Windows, you can execute the command "netstat -ano | findstr 8080" to check if the port number is occupied by any other program.

Step 4: Make sure the following lines are NOT commented out in the httpd.conf file.

LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so

Step 5: Check if any syntax error in httpd.conf.

cd C:\Apache24\bin
httpd -t

Step 6: Restart Apache for the changes to take effect.

httpd -k restart

Step 7: View the ..\Apache24\logs\error.log file to make sure Apache is started successfully.

[Wed Jun 02 00:46:00.547040 2021] [mpm_winnt:notice] [pid 1556:tid 696] AH00455: Apache/2.4.47 (Win64) configured -- resuming normal operations
[Wed Jun 02 00:46:00.547040 2021] [mpm_winnt:notice] [pid 1556:tid 696] AH00456: Apache Lounge VS16 Server built: Apr 24 2021 11:08:47
[Wed Jun 02 00:46:00.547040 2021] [core:notice] [pid 1556:tid 696] AH00094: Command line: 'c:\\apache24\\bin\\httpd.exe -d C:/Apache24'
[Wed Jun 02 00:46:00.547040 2021] [mpm_winnt:notice] [pid 1556:tid 696] AH00418: Parent: Created child process 4860
[Wed Jun 02 00:46:01.143540 2021] [mpm_winnt:notice] [pid 4860:tid 728] AH00354: Child: Starting 64 worker threads.

Step 8: If you have set up a firewall on the server, configure the firewall to allow port 8080 (by following instructions in "Configuring Windows Defender Firewall").

Note

If the firewall blocks the port number, you will have the following error when running the application.


Modifying and re-deploying the PowerServer project

The following modifications are made to the PowerServer project created in the Quick Start guide. If you have not created a PowerServer project yet, please follow the instructions in the Quick Start guide to create one.

Step 1: Modify the Web API URL to point to the Apache reverse proxy server.

On the Web APIs tab of the PowerServer project painter, specify the URL of the Apache reverse proxy server, for example, http://172.16.100.35:8080 in this tutorial. All requests for PowerServer Web APIs will be first made to http://172.16.100.35:8080 and then redirected by the Apache reverse proxy server to the PowerServer Web APIs running on Kestrel server (for example http://172.16.100.35:6000).


Step 2: Select a Web server for deploying the app files.

On the Client Deployment tab of the PowerServer project painter, select a local or remote Web server (IIS, Apache, Nginx, etc.) you have configured properly.

The Web server and the Apache reverse proxy server can reside in the same or different machine. If the Web server is an Apache HTTP server, it can be the same or different server instance with the Apache reverse proxy server.

In this tutorial, we use the same Apache server instance as the Apache HTTP server and the reverse proxy server.

  • If you choose the "Directly deploy to the server" option, make sure you have configured the FTP settings properly for the server. See Setting up Apache on Windows > Installing FTP server for detailed instructions.

  • If you choose the "Package the compiled app and manually deploy later" option, follow the instructions in Packaging and copying the client app.


Step 3: Save the PowerServer project settings and then build and deploy the PowerServer project for the changes to take affect.

Starting Web APIs

In this tutorial, we will run the PowerServer Web API as a standalone console application on its own internal Kestrel Web server, by using either of the following methods:

  • Execute the "dotnet run --project PowerServer19\ServerAPIs\ServerAPIs.csproj" command, or

  • Open the PowerServer Web API solution in the SnapDevelop IDE or Visual Studio IDE and then click the Run button.

Make sure the PowerServer Web API is running on the correct IP address and port number. For example, http://172.16.100.35:6000/ in this tutorial. You may modify the port number in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.


When you run the application (http://172.16.100.35:80/pssales in this tutorial), you will be able to see from the console that the requests are going through successfully and the requests are originally made to the Apache proxy server (http://172.16.100.35/8080 in this tutorial).

Configuring Apache reverse proxy server (Linux)

Preparations

In this tutorial, we will learn how to set up Apache on Linux and use it as the reverse proxy server to redirect requests to the PowerServer Web APIs running on the Kestrel server.

In this tutorial, we will configure and use the following server environment and URLs. Be careful to use the correct port number and make sure the port is not occupied by any other program.


Step 1: Set up the reverse proxy server with the following OS and software (install the software in the order listed).

Step 2: Configure the CentOS user account: you can either use the root account or create a new account with administrative privileges.

Step 3: Set up a firewall on the server and make sure the firewall allows the port (80 and 8080 in this tutorial or any port number you choose) to go through.

Step 4: Make sure the server can connect to Internet during the installation of Apache HTTP Server.

Configuring Apache

This section is to configure Apache as a reverse proxy server in a Linux machine.

Step 1: Go to the /etc/httpd/conf folder and open the httpd.conf file in a text editor.

Step 2: Add the following scripts to the end of the httpd.conf file.

This is to configure Apache as a reverse proxy server which will redirect requests made to the URL: http://172.16.100.40:8080/ to the PowerServer Web APIs running on Kestrel at http://172.16.100.35:6000/.

# Listen on port 8080 or any port you choose. Make sure it is not used by any other program. 
<VirtualHost *:8080> 
 ProxyPreserveHost On
 # Pass all requests received at the root http://172.16.100.40/8080 to http://172.16.100.35:6000/ (PowerServer Web APIs running on Kestrel server) and in reverse.
 ProxyPass / http://172.16.100.35:6000/ 
 ProxyPassReverse / http://172.16.100.35:6000/
</VirtualHost>

Step 3: Locate the following line in the httpd.conf file and specify the port number: 80 (or any port you choose) is used to access the static Web files on the Apache HTTP server, 8080 is used to access Web APIs (according to the reverse proxy setting in step 2, requests made to 8080 will be forwarded to 6000.)

Change

Listen 80

To

Listen 80
Listen 8080

Tip: In CentOS, you can execute the command "netstat -anp | grep 8080" to check if the port number is occupied by any other program.

Step 4: Run the following command to add port 8080 to "http_port_t":

$ sudo semanage port -a -t http_port_t -p tcp 8080

Note

If the port is not properly added, you may see the following error when you start and check the status of Apache:


Step 5: If you have set up a firewall on the server, run the following command to permanently enable port 8080:

$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp

and the following command to reload the firewall service:

$ sudo firewall-cmd --reload

Note

If the firewall blocks the port number, you may have the following error when running the application.


Step 6: Check if any syntax error in httpd.conf, and then restart Apache for the changes to take effect.

$ sudo apachectl configtest
$ sudo systemctl restart httpd

Step 7: Verify that Apache is running.

$ sudo systemctl status httpd


Step 8: Run the following command to allow Apache to make outbound connections.

$ sudo /usr/sbin/setsebool -P httpd_can_network_connect 1

Note

If Apache is not allowed to make outbound connections, you may encounter the following error when running the application,


and may have the following errors in the \var\log\httpd\error_log.log file.

[Tue Jun 08 05:21:42.408866 2021] [proxy:error] [pid 4025:tid 140605678085888] (13)Permission denied: AH00957: HTTP: attempt to connect to 172.16.100.35:6000 (172.16.100.35) failed
[Tue Jun 08 05:21:42.408952 2021] [proxy_http:error] [pid 4025:tid 140605678085888] [client 172.16.100.35:56187] AH01114: HTTP: failed to make connection to backend: 172.16.100.35
Modifying and re-deploying the PowerServer project

The following modifications are made to the PowerServer project created in the Quick Start guide. If you have not created a PowerServer project yet, please follow the instructions in the Quick Start guide to create one.

Step 1: Modify the Web API URL to point to the Apache reverse proxy server.

On the Web APIs tab of the PowerServer project painter, specify the URL of the Apache reverse proxy server, for example, http://172.16.100.40:8080. All requests for PowerServer Web APIs will be first made to http://172.16.100.35:8080 and then redirected by the Apache reverse proxy server to the PowerServer Web APIs running on Kestrel server (for example http://172.16.100.35:6000).


Step 2: Select a Web server for deploying the app files.

On the Client Deployment tab of the PowerServer project painter, select a local or remote Web server (IIS, Apache, Nginx, etc.) you have configured properly.

The Web server and the Apache reverse proxy server can reside in the same or different machine. If the Web server is an Apache HTTP server, it can be the same or different server instance with the Apache reverse proxy server. If you want to deploy the app files to the Apache HTTP server which uses the same server instance as the Apache reverse proxy server on a Linux machine, you can choose "Package the compiled app and manually deploy later" (see Packaging and copying the client app for detailed instructions).

In this tutorial, we choose to deploy the app files to a local IIS Web server.


Step 3: Save the PowerServer project settings and then build and deploy the PowerServer project for the changes to take affect.

Starting Web APIs

In this tutorial, we will directly run the PowerServer Web API as a standalone console application by using either of the following methods:

  • Execute the "dotnet run --project PowerServer19\ServerAPIs\ServerAPIs.csproj" command, or

  • Open the PowerServer Web API solution in the SnapDevelop IDE or Visual Studio IDE and then click the Run button.

Make sure the PowerServer Web API is running on the correct IP address and port number. For example, http://172.16.100.35:6000/ in this tutorial. You may modify the port number in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.


When you run the application (http://172.16.100.72:80/pssales in this tutorial), you will be able to see from the console that the requests are going through successfully and the requests are originally made to the Apache proxy server (http://172.16.100.40/8080 in this tutorial).


Configuring Nginx reverse proxy server (Windows)

Preparations

In this tutorial, we will learn how to set up Nginx on Windows and use it as the reverse proxy server to redirect requests to the PowerServer Web APIs running on the Kestrel server.

The Nginx reverse proxy server can be set up on the same or different server from the PowerServer Web APIs and Kestrel. In this tutorial, the same server will be used.

In this tutorial, we will configure and use the following server environment and URLs. Be careful to use the correct port number and make sure the port is not occupied by any other program.


Step 1: Set up the server with the following OS and software (install the software in the order listed).

  • Windows Server 2019 (64-bit)

  • Nginx 1.19.10

    The section Installing Nginx has detailed installation instructions.

Step 2: Make sure the server can connect to the NuGet site: https://www.nuget.org (for installing PowerServer NuGet packages) and the following Appeon sites: https://apips.appeon.com, https://apipsoa.appeon.com, https://apipsinfo.appeon.com, and https://api.appeon.com (for validating the PowerServer license).

Step 3: Configure Windows Defender Firewall on the server to allow the port number (80 and 8080 in this tutorial or any port number you choose). The section "Configuring Windows Defender Firewall" has detailed instructions.

Configuring Nginx

This section is to configure Nginx as a reverse proxy server in a Windows machine.

Step 1: Go to the ..\nginx-1.19.10\conf folder and open the nginx.conf file in a text editor.

Step 2: Locate the "server" section and add another "server" block as shown below.

This is to configure Nginx as a reverse proxy server which will redirect requests made to the URL: http://172.16.100.39:8080/ to the PowerServer Web APIs running on Kestrel at http://172.16.100.35:6000/.

    server {
        listen  8080;
        location / {
           proxy_set_header Host $http_host;
           proxy_pass  http://172.16.100.35:6000;
        }
    }


Tip: In Windows, you can execute the command "netstat -ano | findstr 8080" to check if the port number is occupied by any other program.

Step 3: Check if any syntax error in the Nginx configuration file, and then restart Nginx for the changes to take effect.

nginx -t
nginx -s reload

Step 4: Verify that the Nginx processes are running.

tasklist /fi "imagename eq nginx.exe"

Step 5: If you have set up a firewall on the server, configure the firewall to allow port 8080 (by following instructions in "Configuring Windows Defender Firewall").

Note

If the firewall blocks the port number, you will have the following error when running the application.


Modifying and re-deploying the PowerServer project

The following modifications are made to the PowerServer project created in the Quick Start guide. If you have not created a PowerServer project yet, please follow the instructions in the Quick Start guide to create one.

Step 1: Modify the Web API URL to point to the Nginx reverse proxy server.

On the Web APIs tab of the PowerServer project painter, specify the URL of the Nginx reverse proxy server, for example, http://172.16.100.39:8080 in this tutorial. All requests for PowerServer Web APIs will be first made to http://172.16.100.39:8080 and then redirected by the Nginx reverse proxy server to the PowerServer Web APIs running on Kestrel server (for example http://172.16.100.35:6000).


Step 2: Select a Web server for deploying the app files.

On the Client Deployment tab of the PowerServer project painter, select a local or remote Web server (IIS, Apache, Nginx, etc.) you have configured properly.

The Web server and the Nginx reverse proxy server can reside in the same or different machine. If the Web server is an Nginx HTTP server, it can be the same or different server instance with the Nginx reverse proxy server.

In this tutorial, we use the same Nginx server instance as the Nginx HTTP server and the reverse proxy server.

  • If you choose the "Directly deploy to the server" option, make sure you have configured the FTP settings properly for the server. See Setting up Nginx on Windows > Installing FTP server for detailed instructions.

  • If you choose the "Package the compiled app and manually deploy later" option, follow the instructions in Packaging and copying the client app.


Step 3: Save the PowerServer project settings and then build and deploy the PowerServer project for the changes to take affect.

Starting Web APIs

In this tutorial, we will directly run the PowerServer Web API as a standalone console application by using either of the following methods:

  • Execute the "dotnet run --project PowerServer19\ServerAPIs\ServerAPIs.csproj" command, or

  • Open the PowerServer Web API solution in the SnapDevelop IDE or Visual Studio IDE and then click the Run button.

Make sure the PowerServer Web API is running on the correct IP address and port number. For example, http://172.16.100.35:6000/ in this tutorial. You may modify the port number in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.


When you run the application (http://172.16.100.39:80/pssales in this tutorial), you will be able to see from the console that the requests are going through successfully and the requests are originally made to the Nginx proxy server (http://172.16.100.39/8080 in this tutorial).


Configuring Nginx reverse proxy server (Linux)

Preparations

In this tutorial, we will learn how to set up Nginx on Linux and use it as the reverse proxy server to redirect requests to the PowerServer Web APIs running on the Kestrel server.

In this tutorial, we will configure and use the following server environment and URLs. Be careful to use the correct port number and make sure the port is not occupied by any other program.


Step 1: Set up the reverse proxy server with the following OS and software (install the software in the order listed).

  • CentOS 8 (64-bit)

  • Nginx

    The section Installing Nginx has detailed installation instructions.

Step 2: Configure the CentOS user account: you can either use the root account or create a new account with administrative privileges.

Step 3: Set up a firewall on the server and make sure the firewall allows the port (80 and 8080 in this tutorial or any port number you choose) to go through.

Step 4: Make sure the server can connect to Internet during the installation of Nginx.

Configuring Nginx

This section is to configure Nginx as a reverse proxy server in a Linux machine.

Step 1: Go to the /etc/nginx/ folder and open the nginx.conf file in a text editor.

Step 2: Locate the "server" section and add another "server" block as shown below.

This is to configure Nginx as a reverse proxy server which will redirect requests made to the URL: http://172.16.100.51:8080/ to the PowerServer Web APIs running on Kestrel at http://172.16.100.35:6000/.

    server {
        listen  8080;
        location / {
           proxy_set_header Host $http_host;
           proxy_pass  http://172.16.100.35:6000;
        }
    }

Tip: In CentOS, you can execute the command "netstat -anp | grep 8080" to check if the port number is occupied by any other program.

Step 3: Run the following command to add port 8080 to "http_port_t":

$ sudo semanage port -a -t http_port_t -p tcp 8080

Note

If the port is not properly added, you may see the following error when Nginx starts:


and may have the following error in the \var\log\nginx\error.log file.

2021/06/09 05:26:29 [emerg] 4107#0: bind() to 0.0.0.0:8080 failed (13: Permission denied)

Step 4: If you have set up a firewall on the server, run the following command to permanently enable port 8080:

$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp

and the following command to reload the firewall service:

$ sudo firewall-cmd --reload

Note

If the firewall blocks the port number, you will have the following error when running the application.


Step 5: Check if any syntax error in the Nginx configuration file, and then restart Nginx for the changes to take effect.

$ sudo nginx -t
$ sudo systemctl restart nginx

Step 6: Verify that Nginx is running.

$ sudo systemctl status nginx

Step 7: Run the following command to allow Nginx to make outbound connections.

$ sudo setsebool -P httpd_can_network_connect 1

Note

If Nginx is not allowed to make outbound connections, you may encounter the following error when running the application,


and may have the following errors in the \var\log\nginx\error.log file.

2021/06/09 02:38:02 [crit] 5364#0: *2 connect() to 172.16.100.35:6000 failed (13: Permission denied) while connecting to upstream, client: 172.16.100.35, 
server: _, request: "POST /api/ServerApi/CreateSession HTTP/1.1", upstream: "http://172.16.100.35:6000/api/ServerApi/CreateSession", host: "172.16.100.51"
Modifying and re-deploying the PowerServer project

The following modifications are made to the PowerServer project created in the Quick Start guide. If you have not created a PowerServer project yet, please follow the instructions in the Quick Start guide to create one.

Step 1: Modify the Web API URL to point to the Nginx reverse proxy server.

On the Web APIs tab of the PowerServer project painter, specify the URL of the Nginx reverse proxy server, for example, http://172.16.100.51:8080. All requests for PowerServer Web APIs will be first made to http://172.16.100.51:8080 and then redirected by the Nginx reverse proxy server to the PowerServer Web APIs running on Kestrel server (for example http://172.16.100.35:6000).


Step 2: Select a Web server for deploying the app files.

On the Client Deployment tab of the PowerServer project painter, select a local or remote Web server (IIS, Apache, Nginx, etc.) you have configured properly.

The Web server and the Nginx reverse proxy server can reside in the same or different machine. If the Web server is an Nginx HTTP server, it can be the same or different server instance with the Nginx reverse proxy server. If you want to deploy the app files to the Nginx HTTP server which uses the same server instance as the Nginx reverse proxy server on a Linux machine, you can choose the "Package the compiled app and manually deploy later" option (see Packaging and copying the client app for detailed instructions).

In this tutorial, we choose to deploy the app files to a local IIS Web server.


Step 3: Save the PowerServer project settings and then build and deploy the PowerServer project for the changes to take affect.

Starting Web APIs

In this tutorial, we will directly run the PowerServer Web API as a standalone console application by using either of the following methods:

  • Execute the "dotnet run --project PowerServer19\ServerAPIs\ServerAPIs.csproj" command, or

  • Open the PowerServer Web API solution in the SnapDevelop IDE or Visual Studio IDE and then click the Run button.

Make sure the PowerServer Web API is running on the correct IP address and port number. For example, http://172.16.100.35:6000/ in this tutorial. You may modify the port number in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.


When you run the application (http://172.16.100.72:80/pssales in this tutorial), you will be able to see from the console that the requests are going through successfully and the requests are originally made to the Nginx proxy server (http://172.16.100.51/8080 in this tutorial).


Configuring IIS reverse proxy server

Preparations

In this tutorial, we will learn how to set up Windows IIS as the reverse proxy server which redirects requests to the PowerServer Web APIs running on the Kestrel server.

In this tutorial, we will configure and use the following server environment and URLs. Be careful to use the correct port number and make sure the port is not occupied by any other program.


Step 1: Set up the reverse proxy server with the following OS and software (install the software in the order listed).

  • Windows Server 2019 (64-bit)

  • IIS

    The section Installing Web Server (IIS) has detailed installation instructions.

  • IIS URL Rewrite

    Download and install the URL Rewrite extension.

    URL Rewrite must be installed prior to ARR, as ARR depends on URL Rewrite.

  • IIS Application Request Routing (ARR)

    Download and install the Application Request Routing extension.

    After installation, you should be able to see the Application Request Routine Cache and URL Rewrite features in the IIS manager.


Step 2: Make sure the server can connect to the NuGet site: https://www.nuget.org (for installing PowerServer NuGet packages) and the following Appeon sites: https://apips.appeon.com, https://apipsoa.appeon.com, https://apipsinfo.appeon.com, and https://api.appeon.com (for validating the PowerServer license).

Step 3: Configure Windows Defender Firewall on the server to allow the port number (80 and 8080 in this tutorial or any port number you choose). The section "Configuring Windows Defender Firewall" has detailed instructions.

Configuring IIS

This section is to configure IIS as a reverse proxy server.

Step 1: Open the IIS manager, select the server in the Connections pane, and then double click Application Request Routing Cache to open the feature.


Step 2: In the Actions pane, click Server Proxy Settings.


Step 3: On the Application Request Routing page, select Enable Proxy; and then in the Actions pane, click Apply. This enable ARR as a proxy at the server level.


Step 4: Select the website (listening on port 8080 in this tutorial) in the Connections pane, and then double click URL Rewrite to open the feature.


Step 5: In the Actions pane, click Add Rule(s).

Step 6: In the Add Rule(s) dialog, select Reverse Proxy and click OK.


Step 7: In the Add Reverse Proxy Rules dialog, input the URL of the PowerServer Web API running on the Kestrel server (http://172.16.100.35:6000/ in this tutorial). Click OK.


Modifying and re-deploying the PowerServer project

The following modifications are made to the PowerServer project created in the Quick Start guide. If you have not created a PowerServer project yet, please follow the instructions in the Quick Start guide to create one.

Step 1: Modify the Web API URL to point to the IIS reverse proxy server.

On the Web APIs tab of the PowerServer project painter, specify the URL of the IIS reverse proxy server, for example, http://172.16.100.81:8080. All requests for PowerServer Web APIs will be first made to http://172.16.100.81:8080 and then redirected by the IIS reverse proxy server to the PowerServer Web APIs running on the Kestrel server (for example http://172.16.100.35:6000).


Step 2: Select a Web server for deploying the app files.

On the Client Deployment tab of the PowerServer project painter, select a local or remote Web server (IIS, Apache, Nginx, etc.) you have configured properly.

The Web server and the IIS reverse proxy server can reside in the same or different machine. If the Web server is an IIS HTTP server, it can be the same or different server instance with the IIS reverse proxy server.

In this tutorial, we choose to deploy the app files to a local IIS Web server.

To use the same IIS server instance as the IIS HTTP server and the reverse proxy server, you can choose from these two options:

  • If you choose the "Directly deploy to the server" option, make sure you have configured the FTP settings properly for the server. See Setting up IIS > Creating an IIS FTP site for detailed instructions.

  • If you choose the "Package the compiled app and manually deploy later" option, follow the instructions in Packaging and copying the client app.


Step 3: Save the PowerServer project settings and then build and deploy the PowerServer project for the changes to take affect.

Starting Web APIs

In this tutorial, we will run the PowerServer Web API as a standalone console application on its own internal Kestrel Web server, by using either of the following methods:

  • Execute the "dotnet run --project PowerServer19\ServerAPIs\ServerAPIs.csproj" command, or

  • Open the PowerServer Web API solution in the SnapDevelop IDE or Visual Studio IDE and then click the Run button.

Make sure the PowerServer Web API is running on the correct IP address and port number. For example, http://172.16.100.35:6000/ in this tutorial. You may modify the port number in the launchSettings.json file of the ServerAPIs project of the PowerServer Web API solution.


When you run the application (http://172.16.100.72:80/pssales in this tutorial), you will be able to see from the console that the requests are going through successfully.