Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In NGINX when setting up my different servers, I find that I have a lot of duplicate settings. For example, this setting returns in each separate server:

location ~ \.php {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

Is there a way to make this global, so that it is shared with different servers?

share|improve this question

migrated from Feb 25 '11 at 17:31

This question came from our site for computer enthusiasts and power users.

yes you could create a file in your nginx folder called say


which could contain those elements

and in the nginx config block where they originally were you would have a line

include /etc/nginx/phpcommon.conf;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.