Are you facing challenges when trying to set up a websocket-based website behind a reverse proxy in IIS? Don’t worry, we’ve got you covered! In this guide, we’ll explore the common issues and provide you with step-by-step solutions to ensure seamless communication between your websocket server and client. Let’s dive in!
Understanding the Situation
Before we delve into the solutions, let’s understand the scenario. You have an IIS server running on Windows 10 Pro, with an SSL certificate from LetsEncrypt installed and managed by Win-ACME. The websocket-based website in question is powered by FoundryVTT, running on a FreeNAS jail with socket.io for Node.js. The FoundryVTT server is accessible via IP address 192.168.2.36 and Port 30000.
Identifying the Issue
Upon testing, you observe that the FoundryVTT server works fine on the local network (LAN). However, when accessed via the internet (WAN) after entering the Admin Access Key, you encounter an empty setup page. This behavior is often caused by misconfigured proxies. Further analysis using tools like Fiddler reveals that the initial HTTP response switches the protocol to websocket (101 response), but subsequent connections seem to fail.
Troubleshooting Steps
To resolve the websocket issue behind the reverse proxy in IIS, follow these steps:
Step 1: Verify WebSocket Protocol Feature
Make sure you have the WebSocket Protocol feature installed on your IIS server. This feature enables IIS to handle websocket communication. To check if it’s installed, follow these steps:
- Open the “Windows Features” dialog on your server.
- Look for the “WebSocket Protocol” feature and ensure it is selected.
- If it’s not selected, enable it and proceed to the next step.
Step 2: Enable Websockets for Your Website in IIS
Once the WebSocket Protocol feature is installed, you need to enable websockets for your specific website in IIS. Follow these steps:
- Open the IIS Manager.
- Select your website from the “Sites” section.
- Double-click the “Configuration Editor” feature.
- In the “Section” dropdown, select “system.webServer/webSocket”.
- Set the “enabled” attribute to “True”.
Step 3: Configure the web.config File
To properly configure the reverse proxy and resolve websocket issues, you need to make adjustments to the web.config file. Here’s an example configuration that you can use as a reference:
code
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- ... Other rules and configurations ... -->
<rewrite>
<outboundRules>
<rule name="ClearWebSocketExtensions" preCondition="ResponseIsHtml">
<match serverVariable="RESPONSE_SEC_WEBSOCKET_EXTENSIONS" pattern="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
<!-- ... Other rules and configurations ... -->
</rewrite>
</system.webServer>
</configuration>
Make sure to include this configuration within the appropriate sections of your web.config file.
Step 4: Restart IIS and Test
Once you’ve made the necessary changes to your configuration, restart the IIS website and test the websocket-based website again. Check if the empty setup page issue is resolved and if the websocket communication is functioning as expected.
Conclusion
By following these troubleshooting steps, you should be able to overcome the challenges of running a websocket-based website behind a reverse proxy in IIS. Ensure that the WebSocket Protocol feature is installed, enable websockets for your website, configure the web.config file, and restart IIS. With these adjustments, your websocket communication should be seamless, allowing you to enjoy the full functionality of your application.
If you encounter any further issues or have specific questions, don’t hesitate to reach out to the FoundryVTT community or consult the IIS documentation for additional guidance.