A simple solution is to solve the problem that Drupal cannot correctly obtain the IP address.

Source: Internet
Author: User
Tags drupal

/**
* Reverse proxy configuration:
* Reverse proxy servers are often used to enhance the performance of websites with large loads and provide additional site cache and security benefits.
* After Drupal is deployed with a reverse proxy server, Drupal's logs, Statistics, and access control systems all need to obtain real user IP addresses.
* Generally, the reverse proxy server adds the X-Forwarded-For header to the request to pass the customer IP address.
* However, the HTTP Header is very fragile for client fraud. Some clients can directly generate this Header information.
* Therefore, Drupal needs to set all proxy server addresses in $ conf ['reverse _ proxy_address.
*
* Activating this setting allows Drupal to obtain the user's IP address from the X-Forwarded-For header.
* The Header name can also be changed to another name through $ conf ['reverse _ proxy_header.
* If you are not sure whether a reverse proxy is used, you do not need to set it if you do not know the meaning of this option, or if the site is hosted on a shared host.
*
* When this configuration is enabled, the address of each reverse proxy server must be saved in $ conf ['reverse _ proxy_addresses.
* If you cannot obtain a complete list of reverse proxy servers (such as CDN) in your environment ). You can directly set $ _ SERVER ['remote _ ADDR '] in settings. php.
* This means that the IP address may be forged.
*/

The code is as follows: Copy code

$ Conf ['reverse _ proxy'] = TRUE;



/**
* If $ conf ['reverse _ proxy'] is set to TRUE, all proxy servers must be listed here.
*/

The code is as follows: Copy code
$ Conf ['reverse _ proxy_addresses '] = array ('A. B. c. D ',...);




If a friend has encountered such a problem like me, set it up first to see if the problem can be solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.