WAMP localhost redirects to my IP - apache

I had to recently wipe my PC and I'm setting up my development environment again using WAMP.
After installing WAMP, if I visit http://localhost instead of seeing the WAMP homepage I get redirected to http://x.x.x.x, where x.x.x.x is my IP.
I had this issue on another PC and after setting the inbound rules for Apache HTTP Server in my Windows Firewall settings to allow all domains it fixed the issue. I applied this to my PC, and the issue does not seem to be present for Internet Explorer, whereas for Chrome and Firefox the localhost to my IP redirect issue persists even after clearing the cache for each browser.
My C:\Windows\System32\drivers\etc\hosts file looks like this:
127.0.0.1 localhost
::1 localhost
and my firewall rules look like this:
I am not currently using vhosts and I'm on a network at my workplace (if that has any implications?)
I also encountered the same issue when using Laragon which uses vhosts and whenever I visited a virtual host, e.g. mysite.dev it didn't work properly either.
My question on the Laragon forum: https://forum.laragon.org/topic/126/accessing-mysite-dev-redirects-to-url-which-shows-index-php-at-root-folder/3

The Problem
I'm behind a proxy which is used for browsing the web at my workplace. The proxy seemed to be messing up the dns resolution whenever I made a call to localhost (when using wamp) or one of my vhosts (when using Laragon).
This was clear as when I ran the following from the command line: ping site.dev I was getting the expected response from 127.0.0.1. However, when going to site.dev in my browser I was getting redirected to my IP, so essentially my etc/hosts file was being ignored for dns resolution.
The difference between the two being that the browser is using the proxy whereas the command line isn't!
The Solution
After trying many different solutions which seemed to work for localhost (on wamp) only, but not vhosts (on Laragon) I finally got to the solution which was actually so simple!
So, for chrome I simply went to chrome://settings/ > Network - Change proxy settings > LAN Settings > Proxy Server - Advanced
Then in the Exceptions text box I added the following:
*.dev;localhost;127.0.0.1
Here's a screenshot of my settings from Chrome/Internet Options
And that did the trick! Hope this can help someone else.

Related

vagrant domain ERR_CONNECTION_REFUSED

I am new here so let me know if i do something wrong :-)
I ran in a bit of trouble trying out Vagrant!
I installed a Vagrant Ubuntu:xenial64 box running apache2 and php 7.1 on it, it all runs smooth I can access it with ssh also in the browser by using the local ip (10.10.10.10) but I also connected a local domain ( test-site.dev ) here I am getting a "ERR_CONNECTION_REFUSED" error. I already try'd many fixed from many topic on the internet but none is working.
forwarded_port ( 80 > 8080 )
Added test-site.dev to /etc/host on Vagrant box
Added test-site.dev to windows host file
Looked at the firewall on the box ( disabled )
Made site in sites-available with the serverName and alias
Try'd other browsers
I am running all of this on a windows 10 machine. Does anyone has more tips for this problem?
EDIT:
Problem was resolved, the problem was the domain extension. .dev seems to be forced with a internal 307 redirect to https. This is wat broke it for me.

apache not serving index.html unless specified

Im new to setting up apache - the site works fine on localhost but when I access it from the LAN it does now display the index.html file - instead the browser says:
This site can’t be reached
localhost refused to connect.
Ive tried editing the apache2.conf file but nothing seems to work
I think you made another mistake. When you are on a different Computer on you network, the Apache server is not available on http://localhost/ but on the domain name or IP of the Apache Server.
The browser tries to open a connection to your client computer. But its not on localhost.

Unable To Connect To MAMP Server From Other Devices

I have MAMP PRO running locally on my machine (Mavericks). I can connect find to localhost and apache is running on port 80.
The test website I have set up is served. I can browse to it via http:// my-local-host (have to put a dash in because stack exchange doesn't like URLs) or http://mymachinename.local or http://XXX.XXX.X.XX (my ipaddress).
It's not working remotely though from either iPhone or iPad. I have tried turning off the firewall. I have tried adding a rule to the firewall to allow incoming connections to httpd. Neither work.
I also have Little Snitch installed. I tried turning off Little snitch and also creating a rule to allow traffic through to port 80 via httpd. Neither work.
Anyone else had similar issues and found a resolution?
The problem is DNS.
MAMP writes your Hosts to /etc/hosts.
Example:
127.0.0.1 example.com
Your Iphone's host file has no such entry. This is why it does not work.
You need e.g. a "DNS-server", which you can enter in
Settings - Wlan - static as Router on your phone.
I think your problem would be addressed if you use the Dynamic DNS option in MAMP PRO. Then, using a third party company like noIP.com, you could setup myTestBox.ddns.net and pull up your website on your iPad.

How do I point a domain back to my own machine? (only for my own browser)

I want to set up a machine for testing a website before launching it. Some of the tests require logic in parsing the current host.
I want to be able to test it in my browser but i can only access it through the localhost.
I want to know how to make my browser resolve my domain to 127.0.0.1:80. (Also I don't want my DNS record to point to my test machine, this should be a local test only).
Also, is there a way to make all sub-domains of my domain access 127.0.0.1:80 as well?
Extra Info --
OS: Windows 7
Browser: Chrome
Web Server: Tomcat 7
Thank You.
EDIT ---
The solution was to add a few lines to the host file:
127.0.0.1 example.com
etc.
You're looking for the hosts file. It's more than likely what points localhost to 127.0.0.1 on your computer.
You can find it at C:\Windows\System32\drivers\etc\hosts on Windows. Or /etc/hosts on most Linux systems, if you're interested.

iis and apache combination on real server for 403

We have a win2003 server that run both IIS 7 and apache (using wamp server 2.2).
We put on both server a page named test.html that show us a message that say "You are on IIS page" and "You are on WAMP page" to show us if everything is working correctly.
Both running real great locally. IIS is listening on port 80 and apache on port 8082. The problems come remotly. Both services are running and wamp is fully online (green icon + "put online" option activate).
Locally, on the server, doing http://localhost/test.html and http://localhost:8082/test.html show the correct pages. If we replace localhost by real IP address (for example purpose, let say http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html), still work. (not actual address but address used for real is the same used by dns web service)
Remotly, from any other PC, doing http://10.2.5.16/test.html and http://10.2.5.16:8082/test.html, the first give us the website normally, the second give us a HTTP 403 FORBIDEN (tried using both htaccess and windows permission, still have 403). The same way, using http://www.ourdomain.com/test.html and http://www.ourdomain.com:8082/test.html give us the exact same result (first ok, second 403)
Is it possible to make it work correctly?
Thanks in advance.
edit: Just to add to the solution :
the firewall was blocking me, add the wamp on this port allowed
in my configuration, i had in my directory statement Require local, which needed to be set to Require all granted
for the rest, the solution was pretty it.
Thanks again.
The fact that you can get to the sites locally tells me both servers are setup correctly and listening on respective ports.
Upon further questions, the OP indicated that the Servername Directive, is pointing to localhost and it should be changed as.
ServerName localhost:8082
To
ServerName example.com:8082 # or add "ServerAlias example.com:8082" to your existing.
Where as example.com is your site DNS. Then in your [System32\drivers\etc\hosts] point that DNS to the ip of your Remote host.
403 is happening because the request from the remote is not matched against any Servername or ServerAlias and it falls to the default handler which normally has stricket permissions. If you look closely in logs(/logs/apache/access.log), there should be something about "access denied by server configuration /somelocation like your default DocRoot"
If you make request for http://example.com and you have correct ip in your hostfile, you can trace what happens to that request in the remote host and where it ends up(firewalls, Apache etc). Apache is good at logging and you just need to find relevant log entries!