How to publish an lsFusion project to the internet using ngrok without using a domain name?
I have a problem: Tomcat publishes successfully on its standard port, but lsFusion, which runs on a different port, doesn’t publish correctly. How can I solve this problem with publishing an lsFusion project through ngrok?
Publishing an lsFusion Project Through ngrok Without Using a Domain
To publish an lsFusion project through ngrok without using a domain, you need to set up a tunnel for the port where lsFusion runs and properly configure Tomcat to handle requests correctly. The main problem is usually related to lsFusion requiring correct host and port headers for proper request routing.
Contents
- Setting up ngrok for lsFusion project
- Main problems and their solutions
- Step-by-step setup instructions
- Configuring Tomcat to work with ngrok
- Final verification and testing
Setting up ngrok for lsFusion project
To publish lsFusion through ngrok without a domain, use the free version of ngrok, which automatically creates temporary subdomains. The main setup steps are:
-
Install ngrok: Download and install ngrok from the official website ngrok.com
-
Run a tunnel for lsFusion: If lsFusion is running on port 8081, execute the command:
ngrok http 8081 -
ngrok free domains: The free version provides addresses in the format
your-id.ngrok-free.app
Important: The free version of ngrok creates random addresses on each run. A permanent address requires a paid subscription.
The main problem occurs when lsFusion doesn’t correctly identify the host and port, leading to errors in the application’s operation.
Main problems and their solutions
Problem 1: lsFusion doesn’t recognize the correct host
lsFusion may not properly handle requests from ngrok because it expects requests to its main domain.
Solution:
- Configure lsFusion with the correct host specified
- Use startup parameters to specify the host and port
Problem 2: Conflict between Tomcat and lsFusion
Tomcat runs on one port (e.g., 8080) while lsFusion runs on another (e.g., 8081). Ngrok should properly route requests.
Solution:
- Set up separate tunnels for each application
- Use different ngrok ports for each service
Problem 3: CORS and security
Some browsers block requests from different domains.
Solution:
- Configure CORS headers in ngrok
- Use the
--host-headerparameter to rewrite headers
Step-by-step setup instructions
Step 1: Determine the lsFusion port
Find out which port your lsFusion server is running on. This is usually port 8081 or another port different from Tomcat.
Step 2: Run ngrok for lsFusion
Open a terminal and execute the command:
ngrok http 8081
where 8081 is the port of your lsFusion server.
Step 3: Configure lsFusion startup parameters
Add parameters to specify the correct host:
java -jar lsfusion-server.jar --host=0.0.0.0 --port=8081
Step 4: Check accessibility
After starting ngrok, copy the provided URL (e.g., https://abc123.ngrok-free.app) and open it in your browser.
Step 5: Configure settings
If lsFusion still doesn’t work, configure the ngrok configuration file:
authtoken: your_token
tunnels:
lsfusion:
addr: 8081
proto: http
host_header: rewrite
Configuring Tomcat to work with ngrok
Since Tomcat is working but lsFusion is not, it’s important to properly configure both services:
Tomcat Configuration
Tomcat typically requires configuration to work with a reverse proxy:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
proxyName="your-ngrok-domain.ngrok-free.app"
proxyPort="443"/>
lsFusion Configuration
For lsFusion, add JVM parameters:
-Dserver.port=8081
-Dserver.address=0.0.0.0
-Dserver.forward-headers-strategy=framework
Alternative approach: One tunnel for both services
You can set up a single ngrok tunnel that redirects requests to different ports:
ngrok http localhost:8080,localhost:8081
Final verification and testing
Functionality Check
- Ensure both services are running
- Check accessibility through the ngrok URL
- Check logs for errors
- Test basic lsFusion functions through ngrok
Troubleshooting common errors
- ERR_NGROK_3200: Verify that the lsFusion port is accessible locally
- Timeout errors: Increase timeouts in ngrok settings
- CORS errors: Add necessary headers to the configuration
Permanent settings
To make settings persistent, create an ngrok.yml file in your home directory:
authtoken: your_token
tunnels:
lsfusion:
addr: 8081
proto: http
Sources
- Official ngrok documentation - Custom Domains
- Setting up ngrok using configuration files
- ngrok setup guide in ServBay
- Configuring Tomcat behind a reverse proxy
- ngrok basics for beginners
Conclusion
- Main problem: lsFusion is not published correctly due to improper handling of hosts and ports
- Solution: Set up a separate ngrok tunnel for the lsFusion port (usually 8081) with the correct parameters
- Practical steps: Run
ngrok http 8081, configure JVM parameters for lsFusion, check accessibility - Additional settings: Use the ngrok.yml configuration file for persistent settings
- Tip: For more complex scenarios, consider setting up a single ngrok tunnel with routing to different ports
Following this guide, you can successfully publish an lsFusion project through ngrok without using your own domain.