olivr1
July 29, 2018, 10:42am
1
Enonic version: 6.14.3
OS: Ubuntu 16.04
I have installed the app as service and I can see that it is up and running. I am now trying to forward port 80 to 8080 without sucess. It does work for http://xxx.sa-east-1.compute.amazonaws.com but for some reason, it does not for ofornecedor.com.br. Any ideas why?
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
# ServerName xxx.sa-east-1.compute.amazonaws.com --> it works here
ServerName ofornecedor.com.br
# ServerAlias xxx.compute.amazonaws.com
ServerAlias http://ofornecedor.com.br -- does not work for some reason
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
enabled = true
mapping.api.host = localhost
mapping.api.source = /api
mapping.api.target = /api
# mapping.a.host = xxx.sa-east-1.compute.amazonaws.com
mapping.a.host = ofornecedor.com.br
mapping.a.source = /admin
mapping.a.target = /admin
mapping.a.userStore = system
# mapping.b.host = xxx.sa-east-1.compute.amazonaws.com
mapping.b.host = ofornecedor.com.br
mapping.b.host = localhost
mapping.b.source = /
mapping.b.target = /portal/master/ofornecedor
Is there a better way to have enonic to listen to port 80 without redirecting it?
THx in advance
olivr1
July 30, 2018, 8:47am
2
THe question here is how do I make the app to listen to port 80 instead of 8080?
Seems you have two host lines in config. So I asume localhost is being used by the server
mapping.b.host = ofornecedor.com.br
mapping.b.host = localhost
//runar
olivr1
July 30, 2018, 9:35am
4
@rbrastad silly mistake. you are right, I’ve corrected my mistake and now I can access the site on port 8080. What is the best practice to make the app to listen to 80? Redirecting using apache or setting up some other way?
Hi,
For PROD I always use a frontend HTTP server. But for simple POC and TEST I just change the jetty config file.
//Runar
tsi
July 30, 2018, 9:47am
6
Here is documentation on how to use Apache as a reverse proxy.
https://xp.readthedocs.io/en/6.15/operations/reverse-proxy.html
olivr1
July 30, 2018, 10:13am
7
@tsi @rbrastad Thank you for your help. I will take a look at it.
olivr1
July 30, 2018, 10:52am
8
I came up with the following config.
vhost
enabled = true
mapping.api.host = localhost
mapping.api.source = /api
mapping.api.target = /api
mapping.a.host = ofornecedor.com.br
mapping.a.source = /admin
mapping.a.target = /admin
mapping.a.userStore = system
mapping.b.host = ofornecedor.com.br
mapping.b.source = /
mapping.b.target = /portal/master/ofornecedor
000-default.config
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName ofornecedor.com.br
ServerAlias http://ofornecedor.com.br
ProxyPass /admin/event ws://localhost:8080/admin/event
ProxyPassReverse /admin/event ws://localhost:8080/admin/event
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Do you see anything wrong here? It is not redirecting to port 8080.
I have ec2 instance created pointing to a domain in Route 53 hosted zone. I am not sure if this has something to do with.
olivr1
July 30, 2018, 1:40pm
9
I am receiving
Virtual host mapping could not be resolved for host [www.ofornecedor.com.br] and path [/]
from the server, however I can access the site on port 8080 ( www.ofornecedor.com.br:8080/#/dashboard ).
Very strange.
olivr1
July 30, 2018, 8:18pm
10
@tsi @rbrastad can we use nginx instead of apache2 ? I can’t really figure out the issue here, so I was thinking to give a try on nginx .
tsi
July 30, 2018, 9:11pm
11
If you can reach port 8080, at least your firewalling must be wrong.
We use apache2 for everything in enonic cloud, so that will work.
Is there support for writing server aliases with http in front?
tsi
July 30, 2018, 9:15pm
12
Your problem is that you also allow traffic for www.*** to reach xp. Either create a rewrite rule in apache, or add another mapping to XP
olivr1
July 31, 2018, 12:06pm
13
@tsi thank you for your reply. Thanks to you I can now access the site on Default Web Site Page but not if I try www.ofornecedor.com.br/#/dashboard (www )
Your problem is that you also allow traffic for www.*** to reach xp. Either create a rewrite rule in apache, or add another mapping to XP
…which mapping should I add to XP?
This is the actual config I have in the server. What Am I missing here in order to allow the site to be accessible using www.ofornecedor.com.br/#/dashboard ?
enabled = true
mapping.api.host = localhost
mapping.api.source = /api
mapping.api.target = /api
mapping.a.host = ofornecedor.com.br
mapping.a.source = /admin
mapping.a.target = /admin
mapping.a.userStore = system
mapping.b.host = ofornecedor.com.br
mapping.b.source = /
mapping.b.target = /portal/master/ofornecedor
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName ofornecedor.com.br
ServerAlias http://ofornecedor.com.br
ProxyPass /admin/event ws://localhost:8080/admin/event
ProxyPassReverse /admin/event ws://localhost:8080/admin/event
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
dap
July 31, 2018, 1:25pm
14
This is how I would do it.
ServerAlias is what should hold the www alternative
The first three lines after RewriteEngine on
is a better way to do proxypass for websocket.
If you need websocket for the whole site, change the lines
RewriteCond %{REQUEST_URI} / [NC]
RewriteRule /admin/(.*) ws://exp:8080/$1 [P,L]
You need to add the rewrite module. I have the line as I think it should be. But I usually enable it by running a2enmod rewrite
in the server shell
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
<VirtualHost *:80>
ServerName ofornecedor.com.br
ServerAlias www.ofornecedor.com.br
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteCond %{REQUEST_URI} /admin [NC]
RewriteRule /admin/(.*) ws://exp:8080/admin/$1 [P,L]
RewriteCond %{HTTP_HOST} !^ofornecedor\.com\.br$
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://ofornecedor.com.br/$1 [L,R]
</VirtualHost>
Edit:
Added LoadModule line
1 Like
dap
July 31, 2018, 1:29pm
15
Redacted (but not deleted due to reply to this message)
olivr1
July 31, 2018, 3:41pm
16
@dap thank you so much. The config above worked perfectly .
2 Likes
bwe
Closed
August 1, 2018, 4:00pm
17
This topic was automatically closed after 9 hours. New replies are no longer allowed.