Open ctoabidmaqbool opened 3 years ago
I assume accessing JPro over port 80 and localhost is working with this setup?
was "mydomain.com" just an example, or is your domain managed by "mydomain.com"?
The error message looks to me, that somewhere there is a service, which forwards the WebSocket request - but manipulates the header in some way, so it's no longer a valid WebSocket request.
I guess we will have to make an apache example configuration for our documentation.
@FlorianKirmaier Thanks for reply!
Just to make sure, mydomain.com
is my virtual domain setup on Apache webserver e.g. httpd-vhosts.conf
and is mapped to localhost e.g. 127.0.0.1
.
Actually on port 80 my Apache webserver is listening, And I want to listen jpro.one on this same port too. So I have managed apache ProxyPass
for this task.
jPro.one is now listening on port 80 with my custom localhost domain setup e.g. mydomain.com (http://mydomain.com:80)
But the problem is that my jpro app not go forwards from loading bar.
Note in the exact same setup I can successfully run node.js app e.g. wiki.js
I have edit the question too.
@ctoabidmaqbool I did some research, and according to one of our customers, it doesn't work with ProxyPass. But I don't have any details why.
The issue probably relies on apache not correctly supporting WebSocket when using ProxyPass. Or it's just for some reason complex to set up.
I would recommend running JPro on a different port, and only make it accessible through apache. It's quite easy to set up and known to work.
you will have to enable various apache mods: sudo a2enmod proxy proxy_http rewrite ssl proxy_wstunnel
The configuration of the site might look like the following:
<VirtualHost *:80>
ServerName localhost
RewriteEngine On
# websocket request
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
# kein websocket request
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
</VirtualHost>
This was tested on ubuntu 18.04. Keep us updated, whether this information helps you!
We will create an improved version of this configuration for apache, which will support SSL. This will then be added to our documentation.
@FlorianKirmaier Thanks a lot sir! Your solutions is working like a charm!
So my modified httpd-vhosts.conf
file using your provided solutions is:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName http://mydomain.com
RewriteEngine On
# websocket request
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
# kein websocket request
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
</VirtualHost>
Something like this is enough for my setup including SSL Secure connection e.g. HTTPS
httpd-vhosts.conf
:
# localhost
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
# mydomain.com
<VirtualHost *:80>
ServerAdmin admin@mydomain.com
DocumentRoot "C:/xampp/htdocs/MyApp-jpro"
ServerName mydomain.com
ServerAlias www.mydomain.com
ErrorLog "logs/mydomain.com-error_log"
CustomLog "logs/mydomain.com-access_log" common
<Directory C:/xampp/htdocs/MyApp-jpro>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
ErrorLog "logs/mydomain.com-error_log"
CustomLog "logs/mydomain.com-access_log" common
# Example SSL configuration
SSLEngine on
SSLCertificateFile C:/xampp/apache/conf/ssl/mydomain.com/certificate.crt
SSLCertificateKeyFile C:/xampp/apache/conf/ssl/mydomain.com/private.key
SSLCertificateChainFile C:/xampp/apache/conf/ssl/mydomain.com/ca_bundle.crt
RewriteEngine On
# websocket request
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
# kein websocket request
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
</VirtualHost>
.htaccess
:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
hosts
:
127.0.0.1 localhost
127.0.0.1 mydomain.com
Hi! I want to map jPro-one Server to run on different Url on Apache Server without needing of port writing on Url.
Let my jpro.one server is listening on http://localhost:8080 & my Apache server is listening on http://localhost. I want to map my jpro.one server to this virtual domain url http://mydomain.com.
I try ProxyPass on Apache configuration for this purpose, now my jpro.one can listen on http://mydomain.com but only loading bar is shown, not actual application is loading and error is shown:
What should I do to solve the problem???
My Apache Server (XAMPP) virtual domain setup
C:\xampp\apache\conf\extra\httpd-vhosts.conf
My Windows hosts file e.g.
C:\Windows\System32\drivers\etc\hosts