Connect to multiple local sites on mobile - mobile

I have multiple local sites which I develop on my local machine.
I'd like to be able to access them on a mobile device while they are still local on my machine.
Using XAMPP these are example vhosts configs:
<VirtualHost *:8080>
DocumentRoot "C:/design and photos/agency1/website/public_html"
ServerName agency1dev.com
<Directory "C:/design and photos/agency1/website/public_html">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:/design and photos/captives/website/public_html"
ServerName capdev.com
<Directory "C:/design and photos/captives/website/public_html">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Windows hosts file
127.0.0.1 agency1dev.com
127.0.0.1 capdev.com
I understand I can use my machines IP address to reach e.g.:
http://196.168.2.3:8080
But this goes to the XAMPP dir, so, how do I access e.g. agency1dev.com?
Is this possible?

You can try using Finch, https://meetfinch.com
It's very easy to use (recently released a GUI for it) and just 'works' without having to do anything.
Full disclosure: I'm involved in the project.

The solution I found was using NGROK
Very easy to implement:
In cmd or some shell
Go to: C:\path\to\ngrok
Type:
ngrok http -host-header=myapp.dev 8080
Change myapp.dev to suit what you want to look at - and change port (8080) accordingly
Then look at output and it will give you a http and https url to navigate to on your device
Simple!

Related

What is the correct way to set up a virtual host running on Apache?

I configured apache on ubuntu 16.04 and I created a virtual host with these instructions:
<Directory /var/www/html/example.com/public_html>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
</VirtualHost>
when I try to open the page www.example.com on my browser I see this message:
This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.
Should I use another name instead of "example" to solve the problem?
Ok any name? For example "myname.com"
For clarity, I only need this for local tests
www.example.com is actual website that somebody else owns, has it registered in DNS and has some content on it. When you open the address in browser, your computer first asks DNS server (presumably one setup by your ISP). DNS then responds, that www.example.com is ran on 93.184.216.34 - which is probably not your machine. This is where the message is from.
Now, what is the meaning of ServerName and ServerAlias then? It is actualy a directive for your webserver, running on your machine, to know which packets are meant for given virtual host. It does not affect how your browser will transalate them.
For the sake of local testing (both server and browser are on same OS), all you need to do is to create virtualhost for a 'localhost'. This is a reserved address for the machine currently being used. Simply put:
ServerName localhost
ServerAlias localhost
into your virtualhost and you will be able to access the webserver by entering 'localhost' into your browser.
In case you would need more than one host locally, you can override the dns by editing the host file https://en.wikipedia.org/wiki/Hosts_(file) - for example, in windows by adding hosts records like:
127.0.0.1 app.local
127.0.0.1 db.local
and then creating two different virtual hosts, one with alias app.local, second with db.local. Then, the OS will then route requests from your browser correctly to your machine per hosts file. Your websever will then sort your request according to the header to proper virtualhost.
You might want to check out some general information on how dns and internet protocol works:
https://en.wikipedia.org/wiki/Internet_protocol_suite
https://en.wikipedia.org/wiki/Internet_Protocol
https://en.wikipedia.org/wiki/Domain_Name_System

403 Forbidden after changing DocumentRoot

So, I've tried running a domain, a sub domain and another domain on one machine. I've set up a conf file for every site:
<VirtualHost *:80>
ServerName websitea.com
ServerAlias www.websitea.com
DocumentRoot /var/www/html/weba
</VirtualHost>
<Directory /var/www/html/weba>
Order allow,deny
Allow from all
Require all granted
</Directory>
The same folder config can be found in apache2.conf as well (I tried experimenting with it) and it's the same config across all sites.
The issue is that after putting this DocumentRoot and disabling 000-default.conf I get 403 forbidden.
What I've tried doing so far:
Changing owner to www-data:www-data
Changing perms to 755/777
Putting the directory configurations in
apache2.conf or the website's conf putting all sites in 1 file
all kinds of directory settings (Options Indexes FollowSymLinks,
AllowOverride none/all, Require all granted, Allow from all, Order
Allow,Deny)
but none would work...
EDIT: I found out that the website goes to /www/var/html/ even though the domain is set to get to /www/var/html/weba, DocumentRoot pretty much does nothing in the configurations.
It seems you created a new virtual host configuration file on this path /etc/apache2/sites-available/
you need to enable the website virtual host conf file, for example, id website virtual host conf file name is 'websitea.conf'
then you need run below command
sudo a2ensite websitea.conf

virtual hostname instead of i.p. address in mediawiki

I am trying to replace my i.p. address from my mediawiki with a virtual hostname. My system information are
O.S.: Opensuse 13.1
Mediawiki: 1.26.1
apache2 and mysql
I have edited the /etc/apache2/vhosts.d/mydomain.conf file like this
<VirtualHost 123.456.78.90>
ServerAdmin webmaster#localhost
ServerName www.mylabwiki.org
DocumentRoot /srv/www/htdocs/mylabwiki
ErrorLog /var/log/apache2/myabwiki-error_log
CustomLog /var/log/apache2/mylabwiki-access_log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
<Directory "/srv/www/htdocs/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Require all granted
</Directory>
<Directory "/srv/www/htdocs/mylabwiki">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have edited the /etc/apache2/listen.conf file like this
NameVirtualHost 123.456.78.90
Then I have executed
vi /etc/hosts
123.456.78.90 www.mylabwiki.org
Then I restarted the apache2
service apache2 restart
My problem is, it works only locally. If I use the browser from the host computer, the domain 'www.mylabwiki.org' works properly.But, if I type from a remote computer www.mylabwiki.org and try to connect, it says that the url doesn't exist. However, if I type http://123.456.78.90/ then works perfect from the remote computer. Can anyone tell me where did I miss something! I can feel that I am just one step away, but unable to figure it out.
Your issue is that www.mylabwiki.org is known only on your localhost, because you edited the /etc/hosts to have a local DNS resolution. Your remote computer do not get that information to know where to go.
There is 3 ways to solve the issue:
you edit the /etc/hosts on the remote computer as well, but that means it will work on your localhost and remote computer, but not on nay other. So a real solution.
you have a DNS local server, and you edit the server to resolve the name to the IP address. That will work for all computers on your network, not the outside world.
you record this information in a domain name provide like name.com (or any other), so anyone in the world would know how to resolve the domain to the IP address. For sure it means the IP/computer can be accessed from outside your network.

Test mobile website

I am developing a mobile website and so far I have been testing it in Chrome. Now I would like to test it on my phone.
I am using WAMP and in my hosts file I have the following:
127.0.0.1 www.mysite.com
In my httpd.conf:
<Directory />
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "D:/Path/to/website/root"
DirectoryIndex index.php
</VirtualHost>
What should I type in my mobile browser to hit this website? Do I need to change some WAMP settings or anything else?
Add a rule to httpd.conf or to an alias file for your project:
<Directory "D:/Path/to/website/root">
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1.
</Directory>
MAke sure you restart apache after chaging configuration to see the effects. You may also need to put WAMP "Online" by clicking on the icon in the system tray and choosing "Put Online".
Then try accessing you page using the host computer's local IP address.

Hosting multiple sites with Apache2

I have on a server machine a local domain called "localwiki.com" that points to /var/www/wiki and works fine.
The sites-available and sites-enable configuration:
<VirtualHost *:80>
DocumentRoot /var/www/wiki/
ServerName localwiki.com
ServerAlias *.localwiki.com
</VirtualHost>
I wanted to create a second local domain for /var/www/doxygen (which I can access using "serverIP"/doxygen).
Here is the localdoxygen.com config file created at /etc/apache2/sites-available/localdoxygen.com
<VirtualHost *:80>
DocumentRoot /var/www/doxygen/
ServerName localdoxygen.com
ServerAlias *localdoxygen.com
</VirtualHost>
I used "a2ensite" in order to create a symbolic link in sites-enable pointing to localdoxygen.com in sites-available:
sudo a2ensite localdoxygen.com
I also have reloaded the new configuration:
sudo /etc/init.d/apache2 reload
And restarted apache:
sudo service apache2 restart
But the domain (localdoxygen.com), still doesn't work.
Any suggestions on how to fix this?
To solve the problem I had to add an entry to /etc/bind in order to activate the DNS for the domain.
I think those conf files must end in .conf to be loaded: i.e. localdoxygen.com.conf
disable the default site - a2dissite default (!!!)
DNS correct
check in /etc/apache2/sites-enabled have your sites
reload apache2 /etc/init.d/apache2 reload
You need to define a NameVirtualHost in your apache2.conf to support multiple domains under one IP.
NameVirtualHost 123.456.789.123:80
or
NameVirtualHost *:80
see also Running several name-based web sites on a single IP address.

Resources