how to connect to localhost with virtual domains via wifi? - apache

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.

Related

How to use Apache to reverse proxy to NodeJS app on LAN

I have a LAN network with a server and client at addresses MYSERVER.IP and MYCLIENT.IP.
The server has a nodeJS app running on port 3000. Navigating in the browser from the client machine to MYSERVER.IP:3000/ connects to the app.
I would like to use a custom domain like www.MYTEST.APP/, without a DNS server, and have edited the hosts file on both the client and the server.
Ping to www.MYTEST.APP returns a response from MYSERVER.IP, when tested on both machines. However, http://www.MYTEST.APP/ in the browser is unreachable.
My Apache Virtual Host configuration looks like this:
<VirtualHost *:80>
ServerName MYTEST.APP
ServerAlias www.MYTEST.APP
ProxyPreserveHost On
ProxyPass / http://MYSERVER.IP:3000/
ProxyPassReverse / http://MYSERVER.IP:3000/
</VirtualHost>

Managing multiple sites on XAMPP

I have multiple sites deployed on xampp. For now, all of the sites are using one port i.e. 80. For this reason, whenever I am logged into one of the sites, I am automatically logged out from the other and vice versa. I have looked at this article to How to run multiple websites on XAMPP on Windows. And tried to follow it but I am unable to do the needful.
I have added one more port to listen
Listen 80
Listen 8080
In my httpd-vhosts.conf I have done the following
NameVirtualHost *:8080
<VirtualHost *:8000>
DocumentRoot "F:\xampp\htdocs\mdc"
ServerName localhost:8080
<\VirtualHost>
After doing this I have turned off my xampp and then tried to restart apache and mysql. But apache is not starting
My URL is http://localhost:8080/mdc/backend/web
Note: Without doing any virtual host setting the above URL is accessible on both 80 and 8080 ports
Update 1
Herer is my httpd.conf file
This is not a fix for your issue, Here i will explain how i manage multiple websites on xampp.
First i assumes that your using windows
i always use the same port with different server names.
on : E:\xampp\apache\conf\extra\httpd-vhosts.conf (In my case i installed xampp on E drive)
i added this code
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite1"
ServerName mysite1.flames.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "e:/xampp/htdocs/mysite2"
ServerName mysite2.flames-team.com
</VirtualHost>
And on ( C:\Windows\System32\drivers\etc\hosts) my windows host file i added this lines
127.0.0.1 mysite1.flames.com
127.0.0.1 mysite2.flames-team.com
With this approach you can access the site with a clean readable URLs
In this case if you want to see the first site just enter this URL mysite1.flames.com on browser.
Cheers
Write the closing tag </VirtualHost> instead of <\VirtualHost> in the file httpd-vhosts.conf. I did it and it worked for me.

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.