How to set a custom website name instead of ip address for local computer? - virtualhost

I can point a url to a directory in my computer by setting /etc/host and /private/etc/apache2/extra/httpd-vhosts.conf files. For instance, when i type sample-app.com in my computer, website under /Users/azad/works/sample-app.com folder is running.
When someone type sample-app.com in another computer in same local network i want to display the same website located on my computer. Is this possible?
By the way, i don't have access to any computer in the local network and i can't do any configuration.
Mac 10.7.5 (I am using mac but if windows is better for this purpose i can use windows too),
PHP 5.3,
Apache 2.2

If you want to accomplish this on windows, use the hosts file on the computers you want to point at that sample-app.com URL mapping your IP address to that URL in all the computers you want that to work on. Then make sure your HTTP server is configured to serve that website under that host name for port 80.

Since you aren't able to configure the local network, the best way to handle this situation is to configure a host name with the website domain's DNS server, such as dev.sample-app.com, which points to the local IP address (seeing as how its on the local network) of the computer hosting the website. This will then allow other computers on the local network to enter this host name to access the webiste.
If you had control of the local network's DNS server or control of the proxy (if they have a proxy), there would, of course, be other options.
Update:
Since you mentioned in your comment that you have control over the DNS server, here is how you could accomplish your goal via the DNS server. First, add a forward lookup zone for sample-app.com to the DNS server. Second, configure the default host for the zone to point to the computer serving up the website content. Now the client computers will resolve the local IP when the user enters sample-app.com into their web browsers. If you need to continue to have access to other hosts on sample-app.com, you might want to try asking about it on serverfault.

Related

Host web on local machine use xampp

I want to access my website hosted on local machine on htdocs in xampp, I want to access it using an IP address, How can I get it where like:
https://locahost/
and can I get using an IP address?
can you help me the best tutorial link easy step by step to make it on window 10?
http://localhost:port like http://localhost:8080 i think. You need to specify a port.
You can access your XAMPP website using the following web addresses in the device it is hosted on, usually:
http://127.0.0.1:80
And
http://localhost:80
To access your website from your smartphone or another PC, you will need to access it using your local IP address assigned from your router. Run ipconfig to see it:
You will need to find the line in the output, like: IPv4 Address.........: 192.168.0.123
For port 80 and 443, you do not need to type the number after the address, i.e. :80 or :443. If you are using other ports, you will need to specify them.

Cannot acces to my website through my company LAN network

I am trying to publish a website using a wamp server v3.0.6 located on my own PC. I can access the site from my PC using the domain name "mysite.com" and ignoring the proxy for this site. The problem is that I can not access from other PCs that are on the same LAN network of the company. When I enter "mysite.com" in the browser of another PC without a proxy, an "Unable to connect" message is displayed, and with proxy, it leaves :
Network Access Message: The website can not be found.
Error Code 11001: Host not found
Background: This error indicates that the gateway could not find the IP address of the website you are trying to access. This is usually due to a DNS-related error.
The firewall of my PC is turned off.
What could be the problem?
mysite.com is a domain name. I don't know how you have managed to direct this name to your local machine (editing the hosts file is the simplest approach for that), but you have to make all other computers know about the name-ip pairing you have used. And you need to pair the name with an address that is visible to others (localhost won't do it). If you have a machine that is part of a corporate infrastructure, you might already have a canonical name for your PC, like pc00144.yourcompany.com. If there is no firewall on your PC or the port you are using to serve the web content is open, then all who can ping your pc should be able to connect to your site. If it is the only site in your wamp and it is not configured to use virtual hosts, than it should be connectable by IP also.

Setting domain name for ip address on pi (Apache, DHCP)

I set up my pi to broadcast it's own "wifi" and I have an Apache server running on it.
I used this tutorial https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point
I can currently connect to the network that the pi is broadcasting and go to the ip of the server on my phone and it brings up the webpage, but I want to be able to type in "mydomain.net" and have it bring me to the webpage. Can anyone help me with this or suggest anything?
I want anyone that wants to connect to this local wifi (not worldwide) to be able to enter the website so changing everyone's host file is not going to happen.
you can modify /etc/hosts file on your local machine to point the custom domain name to the IP address of the environment you want to test. The /etc/hosts file contains a mapping of IP addresses to URLs.
Your browser uses entries in the /etc/hosts file to override the IP-address-to-URL mapping returned by a DNS server.
This is only useful for testing DNS (domain name system) changes and the SSL configuration before making a website live.

Does the hosts file affect to adhoc connected devices?

I've got a local Apache2 server on Ubuntu 12.04
with virtual hosts, so in the 'hosts' file I pointed
the virtualhost name to the local IP address -192.168.1.33-.
So 'http://mySite.local' points to '192.168.1.33', it works fine
in the browser.
Now I want to test the same in a cellphone connected to the machine
through a wlan-adhoc network created in my notebook with shared connection.
I can see the root folder if I access to '192.168.1.33' correctly,
but not if I access to 'http://mySite.local'
I assume the '/etc/hosts' file is not affecting the traffic through the adhoc network.
is this correct? Can I change this behaviour? is possible?
You are correct to assume that the hosts file only affects connections that originate from the machine to which the host file belongs. Other traffic already needs to know the IP address it will need to connect to before it reaches your machine. Depending on how much access you have to your phone, getting it to recognize your own domain name like this maybe more work than it's worth.
I say this because you would need to do one of the following:
Edit the equivalent of the hosts file on your phone (if such a file exists in an accessible way)
OR
Set up a local DNS server to serve this info to your phone AND get your phone to use it for DNS resolution.
Without knowing what phone you have, I can't say for sure how hard either of these will be. But I would guess neither one is going to be nearly as easy as typing in the IP and bookmarking it in your phones browser.
The hosts file only works for the machine it is local on. It is not passed on or used as a data source for any DNS service. You would have to have a hosts file local to your cellphone, and I'm not sure that this is possible.

how to make apache server public

I want to convert my pc to a web server. I installed centos server and apache server.
How I can make apache server public? I want to everyone access my web site on my pc via browser.
Thank you..
You have 2 ways, you can buy a domain and a static IP address for your computer (usually through the service provider) and configure your router and FW to allow access to the machine for port 80.
The other way is to use some sort of dynamic dns service like DynDNS to be able to bind a DNS to a dynamic IP address (you will need to run a daemon to update the account once in a while because your IP may change). The FW and router rules are still needed in this case as well.
After you do one of the these steps everyone should be able to access your apache server on your computer as long as it's on.