1

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.

2 Answers 2

2

Configure apache virtual host as a below configuration

For app2

<Virtualhost *:80> ServerName app2.domain.com ServerAdmin [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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> 
Sign up to request clarification or add additional context in comments.

5 Comments

thank you so much @Subhash. now it's working. Now I have to redirect all access to my websites to https. do I have to make three <VirtualHost *:443/> too? or is there a way to redirect all of them in one configuration? thank you.
Hi @Subhash, I have another question, as I have said in my setup I have two machines, they are sharing on 1 Public IP, when I try to redirect all access to app3 (the one I proxy_pass) to https, the page showing is app1. Please help. Thank you.
@carlbasabe please check my answer I add configuration for app3 https redirection.
Hi @Subhash, I tried your config but it still not redirecting to https, do I have to edit the .htaccess of app3? Thank you
0

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> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.