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: https://172.16.100.35:8080/ to the PowerServer Web APIs running on Kestrel at https://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 https://172.16.100.35/8080 to https://172.16.100.35:6000/ (PowerServer Web APIs running on Kestrel server) and in reverse. ProxyPass / https://172.16.100.35:6000/ ProxyPassReverse / https://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. For details, refer to Choosing an appropriate port number.
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 errors 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 the instructions in "Configuring Windows Defender Firewall").