apache2 reverse proxy with domain - proxy

I'm not sure if it's possible what I'm trying to do but I have a few applications on multiple servers. I have one server for gitlab, one for jenkins and one for sonarqube. I want to be able to navigate to them by using my domain as follows:
gitlab > https:// git.mydomain.com
jenkins > https:// jenkins.mydomain.com
sonarqube > http:// sonar.mydomain.com
What I'm trying to do is setup a reverse proxy with apache2 on a 4th server that runs independent from the applications. Here is what I tried to do:
<VirtualHost *:80>
ServerName http:// mydomain.com
ProxyPass http:// sonar.mydomain.com/ http:// sonar.mydomain.com:9000/
ProxyPassReverse http:// sonar.mydomain.com http:// sonar.mydomain.com:9000/
ProxyPass http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
ProxyPassReverse http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
</VirtualHost>
When I do it this way it won't work it will just go to the apache default page. What I did try is doing it with / and I noticed that it won't work with https:// extentions no matter in what way I try to set it. Is there a way to get this working?
and is it possible to set the proxy up the way I want?

Just create three name-based virtualhosts and use "/" as the first parameter for ProxyPass. Each vhost proxies to the corrsponding app.

Related

Laravel 5 - how to change route() and assets() url

When I use the following helpers:
assets('css/app.css');
route('home');
..it generates this URL: "http://myapp.vagrant/css/app.css"
However, I want to change the URL to generate "http://192.168.1.134:8088" as, in my case, a network IP is what I need.
I can find where "myapp.vagrant" is set though. I've change Homestead.yaml and .env files, I've destroyed then vagrant up again. I've tried grep to locate where else this domain might be defined.
Any suggestions? The URL http://192.168.1.134:8088 is pointing correctly to the site but the urls that are generated are using the wrong URL (myapp.vagrant)
Btw here's my apache config file (/etc/apache2/sites-available/myapp.conf):
<VirtualHost *:8088>
ServerName mydomain.com
ServerAlias www.mydomain.com
ProxyPass "/" "http://myapp.vagrant/"
ProxyPassReverse "/" "http://myapp.vagrant/"
</VirtualHost>
So http://192.168.1.134 is the host machine, and I want port 8088 to point to http://myapp.vagrant/ (/etc/hosts points this domain to the vagrant IP) .. unless Laravel is picking up this domain from here?
you can use .env file to set it
APP_URL=http://192.168.1.134:8088

Setup apache2 to forward to Glassfish 4

I have a fresh Ubuntu 16.04 server and a simple html website running with apache 2.
An SSL certificate is also installed. Apache2 is already configured to forward automatically to https.
Furthermore I have a java application running on Glassfish 4 under contextroot myApp. I can access it under http://mydomain.io:8080/myApp
How can I configure apache to forward all requests https://mydomain.io/myApp/ to Glassfish. I don't want to use mod_jk, just apache.
Thanks
UPDATE
In the mean time I tried with mod_rewrite this:
ProxyPass /myApp/ http://localhost:8080/myApp/
ProxyPassReverse /myApp/ http://localhost:8080/myApp/
in /etc/apache2/sites-enabled/000-default.conf
but it's not working!
Finally I solved the problem by inserting following lines
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
in the VirtualHost configuration file located in /etc/apache2/sites-available/. Like suggested in this website.

Tomcat 7 - Ubuntu : create a domain name instead of IP:8080/appName

I have deployed my webapp on an Ubuntu server in my company.
the war is in the folder :
/var/lib/tomcat7/webapps
Tomcat7 has deployed the archive in the folder
/var/lib/tomcat7/webapps/bioApp/
My problem is that to access the web app I need to type the url :
http://IP_OF_SERVER:8080/bioApp
I would like the users to type :
www.bioApp.com
I have tried many solutions (modifying server.xml, hosts file, etc).
None of them work.
If anyone has a working solution...
Thanks
The first thing you need is a local dns server in your company. In your dns server add a rule to route your ip (IP_OF_SERVER) to the local domain name
IP_OF_SERVER bioApp.com
If you had an apache server, you must add a virtualhost in your conf file (See this page for more information)
<VirtualHost *:80>
ServerName bioApp.com
ProxyPass / http://IP_OF_SERVER:8080/bioApp
ProxyPassReverse / http://IP_OF_SERVER:8080/bioAppr
</VirtualHost>
If you don't have a apache server, you can change your tomcat listen port.(See this post).

Mod Rewrite or Mod Proxy setup for tomcat and apache

Assuming I have a domain name called "stackoverflow.com"
I have apache tomcat 7 running an application with context root as /mainsite
I can access this locally as http://stackoverflow.com:8080/mainsite
Apache tomcat is running on 8080 port.
I have apache web server running two more PHP applications on port number 80
one of the Apache application is blog
antoher apache application is forum
my url to access blog is "https://stackoverflow.com/blog"
my url to access forum is "https://stackoverflow.com/forum"
I want to send all requests with url like https://stackoverflow.com/* to mainsite on tomcat
Any url with https://stackoverflow.com/blog or https://stackoverflow.com/forum to be served by apache.
Please let me know how to do this.
I tried some thing like this in httpd.conf
but it is sending every call made to /mainsite.
ProxyPass /blog https://stackoverflow.com/wordpress-3.8.2/wordpress/
ProxyPassReverse /blog https://stackoverflow.com/wordpress-3.8.2/wordpress/
ProxyPass /forum http://localhost/phpBB3/
ProxyPassReverse /forum http://localhost/phpBB3/
ProxyPass / http://localhost:8080/mainsite/
ProxyPassReverse / http://localhost:8080/mainsite/
Thanks in advance for your help.
Do the others work if you remove the last two lines? Proxying the root directory could be a problem, because that also includes the subdirs. I suggest you rewrite the last lines to
ProxyPass /mainsite http://localhost:8080/mainsite/
ProxyPassReverse /mainsite http://localhost:8080/mainsite/
And then add a permanent redirect in the index.html of the apache running at port 80.

Apache how to set company proxy to location

i am trying to set a ProxyPass to my Apache server. I want to set the / location to http://google.de. The problem is, that i am running against the company's proxy server and i need to 'tell' my Apache server that it should use the company proxy server.
This is what i configured:
ProxyRequests Off
ProxyPass / http://www.google.de
ProxyPassReverse / http://www.google.de
is there something like a "setProxy" order? for example the proxyserver of my company is: proxy.company.com:81.
Thanks
I solved the problem, one just need to add the ProxyRemote command:
ProxyRemote * http://proxy.mycompany.com:81
<Location /test>
ProxyPass http://www.heise.de
ProxyPassReverse http://www.heise.de
</Location>
That should work fine. The only problem is, that the relative paths make trouble. I canĀ“t see images and the links are dead.

Resources