How to access Apache virtual host using a mobile device?

After setting up Apache virtual hosts with hostnames "server1" and "server2", how can I access them using my iPhone (or any mobile device), since there is no way to change the / etc / hosts file in iOS or Android?

I understand that you need to refer to virtual hosts by name (assuming you only have 1 IP address on your physical server), but there is no way to map these virtual host names to the same IP address on my physical server.

I run my server on my laptop using MAMP, and my Vonage / Apple Airport router does not support DNS. Do I need to configure a local DNS server? Is there an easy way to run this on my laptop? Thanks.

+4
source share
4 answers

You cannot if you do not have a local DNS. As a workaround, you can configure your first VirtualHost to listen on port 80 and the second on 81 (or 8080 or any ports) and access the server using http: //your.server.ip.addr: port .

+4
source

Adding the following content

HTTPD-vhosts.conf

<VirtualHost *:8080> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/opt/lampp/htdocs/api/www" ErrorLog "logs/app_error" CustomLog "logs/app_log" common </VirtualHost> 

httpd.conf:

 Listen 80 Listen 8080 

Then on your mobile phone you can use:

 http://<your laptop address>:8080/ 
+4
source

You can use IP anti-aliasing and configure IP-based virtual hosts. But then you need to access the sites via IP from your mobile device. But I assume that using different ports, as @Renaud suggests, is easier.

If you want to do this, add an IP alias using ifconfig <interface> inet <ip> add on Mac OS X. Then add the Listen <ip> directive and <VirtualHost ip> directive to your Apache configuration.

+2
source

This link has a good job for this problem.

I apologize after you installed the virtual host.

1.http: //rocketmodule.com/blog/easy-and-free-way-test-local-sites-ipads-iphones-and-other-mobile-devices/

but instead of the path you need to specify a local domain name. for example "king.dev" below

 192.168.1.250(your system ip) king.dev 

in the hosts.ics file on your system.

Now you can access the website from your mobile by typing in your browser, for example.

 192.168.1.250:4000[if you have set the port]/your_file.html 

your local website will be displayed on your mobile device

you can also watch

http://www.tech-otaku.com/local-server/accessing-localhost-virtual-hosts-network-computer/

+1
source

Source: https://habr.com/ru/post/1379352/


All Articles