Problems accessing Apache vhost in Vagrant - apache

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.

Related

Let's Encrypt Unable to find a virtual host listening on port 80

■Background
trying to get SSL through Let's Encrypt
■Issue
As run the code below,
sudo certbot --apache -d hogehoge.com
I got the port 80 error
Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.
and unable to resolve this error
■What I have tried
have set up the port 80
vim /etc/httpd/conf/httpd.conf
add the description in the file.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin root#hogehoge
DocumentRoot /var/www/html
ServerName hogehoge
</VirtualHost>
but I still got the same error.
would you kindly tell me the cause and how to make it work?
Default command "sudo certbot renew" error on localhost
(1)Uninstall certbot
(2)Reinstall certbot
(3)Sudo certbot certonly
(4)Select option 1, spin up temporary web server
(5)Ensure port 80 is accessible from outside, port forwarding in router
(6) Ensure all services using port 80 are stopped
Try
RewriteCond %{REQUEST_URI} !.well-known/acme-challenge
Enabling HTTPS on a Single Instance Beanstalk application: Unable to find a virtual host listening on port 80

how to connect to localhost with virtual domains via wifi?

I have edited "/etc/hosts" where is added: "27.0.0.1 my_page1.localhost", "27.0.0.1 my_page2.localhost" ...
Next I edited "/etc/apache2/sites-available/default" where is added: < VirtualHost *:80 >
DocumentRoot /var/www/my_page1
ServerName my_page1.localhost
< /VirtualHost >
So I can run more sites on localhost with this command "http://my_page1.localhost".
The problem is when I want to connect to localhost with mobile phone 192.168.2.5/my_page1.localhost I receive "Not Found. The requested URL /my_page1.localhost was not found on this server."
How can I connect this localhost site via wifi? On Pc this works.
Use only the ip and the port to connect to sites on your machine from a remote device. Set the servername to SERVERNAME * so it will respond to whatever host you request, reload apache and then connect to 192.168.2.5 on your phone.
For additional vhosts follow this example changing the port number:
Listen 8081
NameVirtualHost *:8081
< VirtualHost *:8081 >
DocumentRoot /var/www/my_page2
ServerName localhost
ServerAlias *
< /VirtualHost >
Reload apache and connect to it using 192.168.2.5:8081 on your mobile phone or localhost:8081.
The config above will direct your request to the correct app based on the port you access.

Vagrant host with forwarded port only shows default index.html

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

Apache named vhost not catching requests that should go to it

I have an Apache server with a group of name-based virtual hosts on it. Requests are sent to the server via an Apache reverse proxy, which forwards all requests for these site names to port 80 on the backend server. While most of these sites appear to be working fine, one vhost is failing to pick up requests for its designated site name, and these are instead being served by the default vhost.
Here's the configuration for the problematic host:
<VirtualHost *:80>
ServerName www.dev.awesome.ac.nz
ServerAdmin netaccount#auckland.ac.nz
ErrorLog logs/awesomeacnz.error.log
CustomLog logs/awesomeacnz.access.log common
Alias / /var/www/html/awesomeacnz/
</VirtualHost>
And here's the output of the Apache vhost diagnostic:
[aful018#wprappdev01 ~]$ sudo /usr/sbin/apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 wprappdev01.its.auckland.ac.nz (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
port 80 namevhost asblog.auckland.ac.nz (/etc/httpd/conf.d/academicservices.conf:1)
port 80 namevhost www.dev.awesome.ac.nz (/etc/httpd/conf.d/awesomeacnz.conf:1)
port 80 namevhost www.dev.auckland.ac.nz (/etc/httpd/conf.d/insideword.conf:1)
port 80 namevhost spearblog.dev.auckland.ac.nz (/etc/httpd/conf.d/spear.conf:1)
port 80 namevhost wordpress-theme.dev.auckland.ac.nz (/etc/httpd/conf.d/theme-dev.conf:1)
Syntax OK
I can't see anything in the above that suggests a problem, but when I send a request for anything on www.dev.awesome.ac.nz the request is served by the vhost for asblog.auckland.ac.nz, which as you can see above is the default host.
Does anyone know why the vhost defined above would not be matching requests for that site? The NameVirtualHost directive in httpd.conf is set to *:80, and other similarly- (not identically-) configured sites on the same server are working fine.
The server is apache 2.2.15 running on Red Hat EL 6.1.

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.