VirtualHosting doesn't work. Logs me in through previous session - virtualhost

When I log in with one browser session, I have to log in, but when I open another session it has automatically logged me in (as if I've picked up session 1), this does not happen if I use http://192.168.0.9:9070
It forces me to log in each time. So I know the application is working, it's just the proxy server that seems to apply the loging to each session (from http://icerap.limeo.com).
# ************************************************************************
# Start of My stuff <<<------------------------------------------------------
# ************************************************************************
#<Proxy *>
#Order Deny,Allow
#Deny from all
#Allow from 192.168.0
#</Proxy>
# blog
<VirtualHost *:80>
ServerName icerap.limeo.com
ProxyPass / http://192.168.0.9:9070/
ProxyPassReverse / http://192.168.0.9:9070/
</VirtualHost>
# www
<VirtualHost *:80>
ServerName helpdesk.limeo.com
ProxyPass / http://192.168.0.9:9055/
ProxyPassReverse / http://192.168.0.9:9055/
</VirtualHost>
# blog
<VirtualHost *:80>
ServerName IceCake.limeo.com
ProxyPass / http://192.168.0.9:9000/
ProxyPassReverse / http://192.168.0.9:9000/
</VirtualHost>
# End of Limeo stuff <<<------------------------------------------------------
# ************************************************************************

VirtualHost directives have nothing to do with authentication or logging in.

Related

Appache virtualhost and proxy

I am trying to redirect a virtualhost to a spefcific ip, in A docker network in my case.
I am on a raspberrypi4 with archlinux.
So, here is my config file, but it do not work, this redirect in my default vhost in local :
<VirtualHost *:80>
#ServerAdmin webmaster#mysite.com
#DocumentRoot "/srv/http/mysite.com"
ServerName mysite.com
ServerAlias mysite.com
ErrorLog "/var/log/httpd/mysite.com-error_log"
CustomLog "/var/log/httpd/mysite.com-access_log" common
ProxyPreserveHost On
ProxyPass "/" "http://172.19.0.5/"
ProxyPassReverse "/" "http://172.19.0.5/"
# <Directory "/srv/http/http/mysite.com">
# Require all granted
# </Directory>
</VirtualHost>
does anybody can help me to fix that ?? :/

Proxy pass an application from a different machine to an apache web server

I have three applications running, 2 on local machine/server where Apache is installed and 1 on a different machine/server.
I am using Apache2.4 on Ubuntu 18.04
application 1(yii) = 127.0.0.1:80
application 2(mantis bt) = 127.0.0.1:8080
application 3(yii) = 192.168.X.X:80
I want to configure my apache web server to host the three applications on https. I proxy pass both app2 and app3.
app2 = /app2 http://127.0.0.1:8080
app3 = /app3 http://192.168.X.X
app1 can be accessed successfully without error,
app2 and app3 can be accessed but .css, .js and other files cannot be found and error 404.
Note: I can access all three apps when not on proxy pass.
also it is possible to host the three apps and have a url like the following:
https://app1.example
https://app2.example
https://app2.example
I am new to apache. Please help me.
Configure apache virtual host as a below configuration
For app2
<Virtualhost *:80>
ServerName app2.domain.com
ServerAdmin youremail#email.com
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
</Virtualhost *:80>
For app3
<Virtualhost *:80>
ServerName app3.domain.com
ServerAdmin youremail#email.com
ProxyPass http://192.168.X.X/
ProxyPassReverse http://192.168.X.X/
</Virtualhost *:80>
Create a separate virtual host for both domains.
After creating virtual host restart apache
service apache2 restart
It's working for me, I hope it will be worked for you and load .css, .js and other files.
If you want to redirect aap3 to https, then your final virtual host file will be like below configuration:
<Virtualhost *:80>
ServerName app2.domain.com
ServerAdmin youremail#email.com
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
</Virtualhost *:80>
<Virtualhost *:80>
ServerName app3.domain.com
Redirect / https://app3.domain.com/
</Virtualhost *:80>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName app3.domain.com
ServerAdmin youremail#email.com
ProxyPass http://192.168.X.X/
ProxyPassReverse http://192.168.X.X/
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias app3.domain.com
SSLCertificateFile /etc/letsencrypt/live/app3.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/app3.domain.com/privkey.pem
</VirtualHost>
</IfModule>
Please check my config below:
DocumentRoot /var/www/html/app1
ErrorLog /var/log/httpd/app1_log
LogLevel debug
<Directory /var/www/html/app1>
AllowOverride none
Order allow,deny
Allow from all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
</Directory>
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
<Location /app2>
ProxyPass http://127.0.0.1:8080/login_page.php
ProxyPassReverse http://1127.0.0.1:8080/login_page.php
SetEnv proxy-sendchunks 1
</Location>
<Location /app3>
ProxyPass http://192.168.X.X/
ProxyPassReverse http://192.168.X.X/
SetEnv proxy-sendchunks 1
</Location>
<Location /static/>
ProxyPass !
</Location>
</VirtualHost>
<VirtualHost *:443>
SSL Configuration
</VirtualHost>

Apache2: reverse proxy subdomain to remote address with port and subfolder?

On my Ubuntu server, I have installed Odoo at http://localhost:8069; Odoo is a Python application, and serves through a Python server.
When http://localhost:8069 is opened first, Odoo checks for currently logged in user; if there is none, it redirects to http://localhost:8069/web/login ; if there is a logged in user, it redirects to http://localhost:8069/web.
I would thus like to make http://localhost:8069/web available on a subdomain, say http://odoo.myserver.com - so the user does not have to be distracted by the port (the :8069 part) and the subfolder (the /web part). In other words, the user should get the login page as http://odoo.myserver.com/login (instead of http://localhost:8069/web/login).
In my case, http://odoo.myserver.com is on the same computer as the one serving Odoo. So, I thought I'd try a reverse proxy in Apache2 for this. This is my subdomain configuration as a virtual host:
<VirtualHost *:80>
ServerName odoo.myserver.com
ServerAdmin info#myserver.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
<Location />
ProxyPass http://127.0.0.1:8069/web/
ProxyPassReverse http://127.0.0.1:8069/web/
</Location>
ProxyErrorOverride off
</VirtualHost>
When I have this active, and load http://odoo.myserver.com in my browser for the first time, I am redirected to http://odoo.myserver.com/web/login, and I get an Odoo styled 404 "Page not found" page.
If I try without a Location tag, and I map /web local to /web remote:
<VirtualHost *:80>
ServerName odoo.myserver.com
ServerAdmin info#myserver.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /web/ http://127.0.0.1:8069/web/
ProxyPassReverse /web/ http://127.0.0.1:8069/web/
ProxyErrorOverride off
</VirtualHost>
... then http://odoo.myserver.com simply gives me the default Apache page, and http://odoo.myserver.com/web/ does redirect to http://odoo.myserver.com/web/login (and something similar happens when I map as ProxyPass(Reverse) / http://127.0.0.1:8069/web/) - but this is not what I want.
EDIT: Closest I got to, was by following https://serverfault.com/questions/698995/apache-proxypass-redirect-subdomain-to-port-and-path :
<VirtualHost *:80>
ServerName odoo.myserver.com
ServerAdmin info#myserver.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8069/
ProxyPassReverse / http://127.0.0.1:8069/
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteRule ^/$ /web/$1 [R,L]
ProxyErrorOverride off
</VirtualHost>
... in which case, when I load http://odoo.myserver.com in my browser, I'm redirected to http://odoo.myserver.com/web/login, and I get a proper Odoo login page. Close enough, but still not there, because the /web part is still visible.
So, how would it be possible to proxy in such a way, that when:
User loads http://odoo.myserver.com - gets http://127.0.0.1:8069/web
User loads http://odoo.myserver.com/login - gets http://127.0.0.1:8069/web/login
...?
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName odoo.myserver.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /login>
ProxyPass / http://127.0.0.1:8069/web/login
ProxyPassReverse / http://127.0.0.1:8069/web/login
</Location>
<Location />
ProxyPass / http://127.0.0.1:8069/web
ProxyPassReverse / http://127.0.0.1:8069/web
</Location>
</VirtualHost>
Try this config

Apache: Site become unavailable when SSL is added

I'm using Apache2 in ubuntu to rout the request to a tomcat webapp. I am also trying to add SSL into this. Below is the apache 000-default.conf file.
<VirtualHost *:80>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
ServerName localhost
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
DocumentRoot /opt/apache-tomcat-7.0.79/webapps/myglukose_messaging_portal/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
# Set the path to SSL certificate
# Usage: SSLCertificateFile /path/to/cert.pem
SSLCertificateFile /etc/apache2/ssl/STAR_myglukose_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/private_key.key
ProxyPreserveHost On
ProxyPass / http://<my-ip>/:8080/
ProxyPassReverse / http://<my-ip>/:8080/
ServerName localhost
</VirtualHost>
Everything was fine until I made the configuration for port 443. When that is made, the site simply becomes unavailable and the browser says "This site can’t be reached. refused to connect.". My tomcat web app is deployed as "ROOT" so can be accessed with the port 80 configuration. Whats wrong here?

Issues Setting up a reverse proxy in Apache

My roommate and I each have a separate webserver we are trying to set up. We are trying to use mod_proxy so that his server will forward requests to my machine (we have two seperate machines behind one router) based on the server name. I've given the basics of what we have in our apache config currently but we are getting a 403 Forbidden error when trying to access the second domain (the first, www domain, works fine).
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www
ServerName www.<domain1>.com
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://<IP addr of other box>:80
ProxyPassReverse / http://<IP addr of other box>:80
ServerName <dummydomain>.gotdns.com
</VirtualHost>
Your mods-enabled/proxy.conf might be blocking any proxy requests (it's deny all by default). It should include the following instead:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
EDIT: Also make sure that the mod_proxy submodules are sym linked into mods-enabled (in this case, the http sub module which is mods-available/proxy_http.load)
Just put both routes:
<VirtualHost *:80>
DocumentRoot "/app/"
ProxyPreserveHost On
ProxyRequests Off
ServerName app.yourdomain.com
ProxyPass /app http://yourIP:yourPort/app/
ProxyPassReverse /app http://yourIP:yourPort/app/
ProxyPass / http://yourIP:yourPort/app/
ProxyPassReverse / http://yourIP:yourPort/app/
</VirtualHost>
<Location "/app/" >
ProxyPass "http://yourIP:yourPort/app/"
ProxyPassReverse "http://yourIP:yourPort/app/"
ProxyPassReverseCookiePath "/app/" "/app/"
ProxyHTMLEnable Off
ProxyHTMLExtended On
ProxyHTMLURLMap "/app/" "/app/"
Order allow,deny
Allow from all
</Location>
This worked form me