B4J Question B4J Web Apps: Apache2 Reverse Proxy

ShaneG30

Well-Known Member
Licensed User
=====Update 1/18/2020=====
I finally figured out why my web apps weren't working with server pilot. It has to do with the "b4j_ws.js" file. I did a slight modification documented below:

Change This:
JavaScript:
fullpath = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + ":" + l.port + absolutePath;
To This:
JavaScript:
fullpath = "ws://" + absolutePath;
This allows me to use ServerPilot as my control panel (as they deal with updates, security updates, AutoSSL, etc) with B4J apps.


=====Update 1/15/2020=====
I have decided to spin up a new DigitalOcean droplet (server) entirely free of ServerPilot and am now running into problems getting my app to function correctly. I can access my app via my droplet's IP address however it does not function correctly. When I go to the subdomain it fails to load completely.

By not functioning correctly I mean the following:
  • By default there should be a "0" in the Your Input Measurement" text field. (There isn't)
  • Clicking the "Convert!" button should actually convert your input measurement. (It doesn't)
My vhost file:

<VirtualHost *:80>
RewriteEngine On
RewriteRule (.*) https://gmu.leftwinggamers.com$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/gmu.leftwinggamers.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/gmu.leftwinggamers.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/gmu.leftwinggamers.com/chain.pem

ServerName gmu.leftwinggamers.com
ServerAlias www.gmu.leftwinggamers.com

ProxyPreserveHost On
RewriteEngine On
ProxyPass / http://127.0.0.1:25115/
</VirtualHost>


Any ideas as to why I'm having this problem with B4J apps?

=====ORIGINAL POST=====

I use DigitalOcean + ServerPilot as my host and am trying to get my web app to work with my ServerPilot "app". It successfully runs and you're able to access it however, I cannot get it to function. (It does function on my local computer and when I access the live app via my server's IP address.)

This is the htaccess I'm using to proxy traffic to the web app:
HTACCESS:
RewriteEngine On[/SPOILER]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule ^(.*) ws://localhost:25115/$1 [P]
RewriteRule ^(.*) http://localhost:25115/$1 [P]
 

Attachments

Last edited:

sorex

Expert
Licensed User
It successfully runs and you're able to access it however, I cannot get it to function
there is some contradiction here.

do you mean it successfully runs on your local server but not on DigitalOcean?

and why don't you correct things inside the app without the rewrite rules?
 

ShaneG30

Well-Known Member
Licensed User
do you mean it successfully runs on your local server but not on DigitalOcean?
It runs on both my computer and DigitalOcean. You can access the app either via the IP Address or the "gmu" subdomain. It functions as intended on the IP Address however, it doesn't function as intended when accessed via the subdomain.

and why don't you correct things inside the app without the rewrite rules?
You can't setup a proxy from within jServer.
 

sorex

Expert
Licensed User
strange. and you're sure that the A record points to the same IP address?

do you need the apache webserver? doesn't the jserver listen to its own port?
 
Top