Should a Mamp Return ::1 as Ip on Localhost

Should a MAMP return ::1 as IP on localhost?

Same question, and found a valid solution, tested, works well. I wanted to have the ip addy - of 127.0.0.1 as well instead of having to accept the the ::1 and debate the whole IPv4/6 issues. So, i trolled for a few moments and fell onto a 2008 comment made by @Brad - here:
http://board.issociate.de/thread/489575/SERVERquotREMOTEADDRquot-returning-1.html

Summarizing - (on Mac OS - Mountain Lion in particular)

sudo vi /etc/apache2/httpd.conf

Find where your apache is 'listen'-ing to the ips/ports, etc...
Typically this will be a line looking like this

Listen 80

Make it look like this:

Listen 127.0.0.1:80

Resave it.
Restart Apache.
Voila!

Now $_SERVER[REMOTE_ADDR] will look like this 127.0.0.1.

Hope it helps someone.

How can I modify my IP address on my localhost in MAMP?

It's ::1 because that's the IPv6 loopback address, equivalent of 127.0.0.1, and the remote address is yourself as MAMP is running locally, the remote browser is on the same machine.

REMOTE_ADDR represents the IP the request came from. In most scenarios this is the same as the IP the browsers machine has on the open-internet, but here MAMP is running Apache natively so it's 127.0.0.1 or ::1. If you were using a docker container or a Virtual machine, it would be a private IP on a range specified when configuring your containers/VMs.

So to retrieve the IP you're expecting, you'll need to use an external service, or, for the sake of debugging, pass Akismet a hardcoded IP, but I suspect it's asking for the IP of whomever is commenting.

MAMP Pro /MAMP/ start page not accessible on local network

@PeterInWiesbaden's answer was helpful in pointing me in the right direction. The issue was that in my (normal) MAMP httpd.conf file I had set all the paths of the MAMP start files to be similar to the following:

Alias /MAMP "/Applications/MAMP/bin/mamp"

<Directory "/Applications/MAMP/bin/mamp">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

but when I edited them in the httpd.conf file directly used by MAMP Pro, these get overwritten each time the server starts, as it uses a template for each Server Name.

To edit httpd.conf for MAMP Pro, it must be done through going to the following in the menu bar:

File->Edit Template->Apache->httpd.conf

And changing the MAMP Pro start pages sections similar to the following:

Alias /MAMP "/Library/Application Support/appsolute/MAMP PRO/mamp"

<Directory "/Library/Application Support/appsolute/MAMP PRO/mamp">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

IP Address of the machine in PHP gives ::1 but why?

::1 is the actual IP. It is an ipv6 loopback address (i.e. localhost). If you were using ipv4 it would be 127.0.0.1.

If you want to get a different IP address, then you'll need to connect to the server through a different network interface.

Trying to access user ip address of the visitor from local host but instead of showing 127.0.0.1 it is displaying ::1

Much simple one:

<?php
$user_ip = $_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']);
echo $user_ip;
?>


Related Topics



Leave a reply



Submit