Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

apache - PHP $_SERVER['REMOTE_ADDR'] empty

Somehow $_SERVER['REMOTE_ADDR'] returns an empty string, i have the same code (as part of a script) running on multiple servers and it works everywhere else, they are all the same setup.

The weird thing is, when I restart apache and load the page, it works exactly once, if I reload the site + all the times after that, it's empty. I've had other people try, same result, empty.

someone suggested it was something with IPv6 configuration, I have now completely disabled IPv6 but the problem persists.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

if you're behind a proxy server, you can use $_SERVER['HTTP_X_FORWARDED_FOR'] or $_SERVER['HTTP_CLIENT_IP'] instead of $_SERVER['REMOTE_ADDR']. this will depends on how your proxy is configured.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...