Vagrant host with forwarded port only shows default index.html - apache

I'm setting up a vagrant machine with a forwarded port.
config.vm.network "forwarded_port", guest: 80, host: 4567
I'm trying to access the site on port 4567 on my host machine, but I can only get the default /var/www/html/index.html from apache.
I set up in my hosts file /etc/hosts the site pointing to the local ip. And I have my site available and enabled in the apache of my vm to port 80.
What am I missing?

I fixed the issue finally. Just in case if someone has the same problem.
I changed in the virtual host configuration from
<VirtualHost site1.myserver.com:80>
to
<VirtualHost *:80>
ServerName site1.myserver.com

Related

Problems accessing Apache vhost in Vagrant

I have Apache server running on Ubuntu in a Vagrant box. In my sites-available directory I have two files:
cats.com.conf
<VirtualHost *:80>
ServerName cats.com
ServerAlias cats.test
DocumentRoot /var/www/cats.com
</VirtualHost>
dogs.com.conf
<VirtualHost *:80>
ServerName dogs.com
ServerAlias dogs.test
DocumentRoot /var/www/dogs.com
</VirtualHost>
In Vagrant I have this port forwarding set up:
Host IP | Host Port | Guest IP | Guest Port
----------------------------------------------
127.0.0.2 | 8000 | 10.0.2.15 | 80
In my hosts file:
127.0.0.2 cats.test
127.0.0.2 dogs.test
But when I visit cats.test in my browser, it can't connect.
Assuming your site does responds correctly when you test it from your Ubuntu VM itself, then it is missing the port in the URL.
https on the Ubuntu VM listens on port 80. When you specified the Vagrant port forwarding:
Host IP | Host Port | Guest IP | Guest Port
----------------------------------------------
127.0.0.2 | 8000 | 10.0.2.15 | 80
it told Vagrant to listen to port 8080, and forward traffic to port 80 of the Ubuntu VM.
Thus on your host system, you have to point your browser to http://cats.test:8080/.
Info: when you connect to a web site with http://example.com/, it defaults to port 80 (http://). For https://example.com/ it defaults to port 443. But http traffic can be handled on any port. You specify the port with :PORT following the domain you want to access.

Access Vagrant VM via virtual host over LAN

I have a web server running inside vagrant virtual machine on my host machine (A). I want another machine (B) to be able to view a website over the LAN.
In my vagrant config I have the following relevant lines of config:
config.vm.network "public_network", ip: "192.168.33.10"
config.vm.network "forwarded_port", guest: 80, host: 8080
In my windows hosts file on host machine (A) I have:
192.168.33.10 awesomewebsite.dev
In the hosts file of the LAN machine (b) I have it pointed towards the IP of machine A
172.123.12.12 awesomewebsite.dev
I have an apache vhost file inside the VM with the following config:
<VirtualHost *:80>
ServerName awesomewebsite.dev
DocumentRoot /var/www/awesomesite
ErrorLog ${APACHE_LOG_DIR}/awesome.log
CustomLog ${APACHE_LOG_DIR}/awesome.log combined
</VirtualHost>
When I visit awesomewebsite.dev on host machine, it works. But when I visit on machine B it doesn't appear to reach machine A. When I visit awesomesite.dev:8080 on machine B it ends up in the wrong web directory and gets permission errors.
I have added the following (just for testing, i know its not high security)
<Directory "/var/www">
Allow from all
</Directory>
I need machine B to access the VM on machine A via the exact virtual host without the port. Is this possible?
with a public network it should just work with the following
192.168.33.10 awesomewebsite.dev
on the Machine B. This machine should be able to see any VMs running on host A and treat it as a separate machine (it is registered on the network with its own network interface)
You then do not work to do any forwarding port when working with static IP as you can just access any port directly from the IP

Connect with public IP (ok) & Domain (not ok) EC2 Windows Instance

here is what I did so far:
I have setup a windows 10 instance
I assigned an Elastic IP
I added rules to the security group
HTTP TCP 80 0.0.0.0/0
Custom TCP Rule TCP 7474 0.0.0.0/0
MYSQL/Aurora TCP 3306 0.0.0.0/0
I assigned the public IP to the domain in the hosted zone as A record
I installed XAMPP 3.2.2
I made sure in httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
is active
In httpd-vhosts.conf I entered
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/my_app"
ServerName myapp.cloud
ServerAlias www.myapp.cloud
<Directory "c:/xampp/htdocs/my_app">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
I also changed hosts on the Windows Server (C:\Windows\System32\drivers\etc)
127.0.0.1 myapp.cloud
I rebooted the system
I started Apache via XAMPP Panel
Results:
I can access myapp.cloud local on the server with RDP session
I can access the public IP from outside and get the XAMPP screen
I can also access publicIP/my_app and get my application
A ping confirms that port 80 is obviously open (otherwise I wouldnt see the XAMPP screen as well)
I CANNOT access the application by typing myapp . cloud - this results in
ERR_CONNECTION_TIMED_OUT
Also Port 7474 seems NOT open although there is an entry
A port check (http://ping.eu/port-chk/) gives:
myapp.cloud:80 is open
myapp.cloud:3306 is open
myapp.cloud:7474 is CLOSED
Apparently the domain resolves correct as a DNS check returns the correct IP
So my issues:
Port 7474 isnt open although set in security
Cant access myapp.cloud although DNS seems right and port 80 is open and listens. (tested on FF and Chrome)
Any hints are very appreciated,
thanks.
######## EDIT ############# 09-11-2017
The problem of the unconnected IP is solved. It was a wrong DNS setting in my internal router - the router didnt renewed the IP settings. So Internet said DNS is correct but private network didnt - I flushed DNS on my PC but forgot to check the router and there was the problem.
Still struggling with the ports ..

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.

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.