my proxy in docker wont link my url to port - apache

Hi I'm a student that's working on a docker project from school.
I have to configure docker with Apache on Ubuntu 16.04. The demand is that I can host multiple applications on one IP with different ports. But I have one problem.... I can't link my urls to the assigned port that I want.
This is my virtual Host file for different containers:
DocumentRoot "/var/www/html"
ServerName site1.docker.biz
Allow from localhost
ProxyPass / http://localhost:80/
DocumentRoot /var/www/html
ServerName site2.docker.biz
allow from localhost
ProxyPass / http://site2.docker.biz:8080/
When I run this file site2.docker.biz links to site1.docker.biz but that's not what I want. I want to link site2.docker.biz to port 8080 instead of port 80.
Can somebody tell me how to do this.
Thank You and kind regards,
Monkeyspree

Why dont you just use port mapping in your docker run statement
docker run -p 8080:80

Related

How to access Virtual Hosts setup on the VM from the Host Machine?

I want to access my virtual hosts (websites) that I've set up in my VirtualBox -> Ubuntu-Server 18. I have apache2 installed and everything is setup.
The host machine (macOS) can presently gain access to the default website of apache2 in the guest (Ubuntu-server) through a Port Forwarding rule I have assigned in the VirtualBox Network Settings:
127.0.0.1:8000 -> 10.0.2.15:80
I've set up a virtual host in my guest machine with the following configuration:
<VirtualHost *:80>
ServerName dropn.taxi
ServerAdmin admin#dropn.taxi
DocumentRoot /var/www/dropn.taxi/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The DocumentRoot directory mentioned above exists and has the files necessary to serve a basic "Hello World" home page. I've tested it with my apache installed in my local machine as well. The website's not the problem.
But everytime I access localhost:8000 from the local machine, I'm greeted with an Ubnutu-Apache greetings page. Whereas when I try localhost:8000/dropn.taxi, I get a 404 page. I've researched quite a bit and the closest I can get to a solution is what is suggested in this page:
Ubuntu Apache2 local virtual hosts url not found
Simply put: How can I access virtual hosts of the guest machine (VM) from the host machine?
Still not specific to my case. Would appreciate any help in this regards.
localhost in the apache2 server is set to point to /var/www/html by default. For the virtual hosts to work properly, the domain name accessing them must be what is defined in the ServerName field.
localhost:8000/dropn.taxi would translate to 127.0.0.1/dropn.taxi in the VM guest. Which means, it is trying to access the /var/www/html/dropn.taxi, which, ultimately does not exist, hence the 404 error.
The solution to this is to add dropn.taxi to the /etc/hosts file in both the Host Machine and the VM. The line would look like:
127.0.0.1 localhost dropn.taxi
While accessing from the Host Machine, we use dropn.taxi:8000 in the browser whereas the port :8000 is not used in the guest machine. This way, whenever accessing the virtual hosts, the domain name accessing them matches the ServerName field and it simply works!

Configure apache2 and host to pass traffic to a docker container with nginx

I'm currently running a ubuntu webserver with apache2, hosting multiple sites and subdomains. I would like to host bitwarden on my own webserver, which is only shipped in a docker container with nginx.
I would like to use a subdomain e.g. bitwarden.domain.com to access bitwarden. But I have no idea how to configure apache2 / host to pass through traffic going to bitwarden.domain.com to the docker container running bitwarden (without affecting the other domains).
My question: How to configure apache2/docker to achieve this? Is there any documentation/tutorial for this?
After starting the docker container, grab the container ip, port:
local_docker_ip, local_docker_port
And you have a couple of options:
Use apache2 Virtual host with a redirect:
<VirtualHost *:80>
ServerName bitwarden.domain.com
Redirect permanent / http://{local_docker_ip}:{local_docker_port}/
</VirtualHost>
Or use the apache2 proxy module. First, enable proxy modules by running the commands:
a2enmod proxy
a2enmod proxy_http
Then, add the following virtual host:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName bitwarden.domain.com
ProxyPass / http://{local_docker_ip}:{local_docker_port}/
ProxyPassReverse / http://{local_docker_ip}:{local_docker_port}/
</VirtualHost>
I hope it helps

Unable to access apache2 virtual host by the servername

I am trying to create a virtual host in apache2 running on VirtualBox guest OS is Ubuntu 14.04 LTS. The following is the configuration of my virtualhost in /etc/apache2/sites-available/mysite.lo.conf
<VirtualHost *:80>
Servername mysite.lo
ServerAlias www.mysite.lo
DocumentRoot /var/www/mysite.lo
</VirtualHost>
Settings in /etc/hosts
127.0.0.1 localhost
172.16.17.146 mysite.lo
When i try to run www.mysite.lo from my host browser, the browser responds no resuts found. When I type the ip address 172.16.17.146 then the browser successfully displays the content of mysite.lo. I would be grateful if someone can guide me on how to access the contents using the servername instead of ip adress. This is the link I have used as a guide to create my virtual host. Regards.
you should add www.mysite.lo to 172.16.17.146 line, or run mysite.lo without www. from host browser.

MAMP Conflict With OS X Lion Apache

I'm trying to get a development environment setup in OS X Lion using MAMP. I've historically had MAMP setup using it's defaults, but now I need to have an environment setup with virtualhosts. To do so, I've done the following:
1) Added to the hosts file:
127.0.0.1 test.com
127.0.0.1 my.test.com
2) Edited httpd.conf and httpd-vhosts.conf (both located in the MAMP folder). For httpd.conf, I simply uncommented the Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf line. For httpd-vhosts.conf, I added:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/username/Sites/test.com"
ServerName test.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/username/Sites/my.test.com"
ServerName my.test.com
</VirtualHost>
3) I changed the ports in MAMP to 80 for Apache and 3306 for MySQL.
4) I turned off personal web sharing in system preferences.
Now, with that set, I experience a redirect when I navigate to "test.com" to test.com:8888". I'm not sure where this is coming from. Then, when I go the "http://localhost", I get the "It Works!" greeting suggesting that the OS X Lion Apache server is running.
Am I missing something with this configuration? Any thoughts?
Thanks so much for your help!
I would see what's running on port 8888. lsof can show you what is running on a network port (please note this may also show outbound traffic, so use a discerning eye when checking port 80).
sudo lsof -i :8888
Note that lsof is normally used to 'list open files' in a directory (hence the name). This is a little known use for the utility.

XAMPP Apache server not working on internal network

I have XAMPP installed on my local laptop (Vista) and it works fine. Apache and MySQL are running as services, and I can get to both http://localhost/ and http://192.168.2.2/ without any hassles.
However, if I try accessing the server from another laptop on my internal network by typing in the http://192.168.2.2/ ip address, it errorstimes out. What am I missing here?
When I run Port Check, I get the following:
Service Port Status
==============================================================================
Apache (HTTP) 80 Program: C:\xampp\xampp\apache\bin\httpd.exe
Apache (WebDAV) 81 free
Apache (HTTPS) 443 Program: C:\xampp\xampp\apache\bin\httpd.exe
MySQL 3306 Program: C:\Program Files\MySQL\MySQL Server 5.1\bin
\mysqld.exe
and when I try telnetting to localhost port 80, that works too. My httpd-vhosts.conf file contains the following lines:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/xampp/htdocs/"
</VirtualHost>
<VirtualHost 192.168.2.2>
ServerName localhost
DocumentRoot "C:/xampp/xampp/htdocs/"
</VirtualHost>
Any thoughts?
Answered via help at ServerFault.com
The problem was that the Windows Firewall had port 80 blocked. To fix this, I opened Windows Firewall, clicked Change Settings, went to the Exceptions tab, and then "Add Port". I set Name to "Web Server (TCP 80)", Port Number to 80, and Protocol to TCP and that was it.