title: The reverse proxy that configured Nginx for HTTP traffic appears 403
body: <p>I'm trying to use Nginx as a reverse proxy in and centos 6.9_64 environment where clients connects to my server (<a href="http://www.51ti.vip" rel="nofollow noreferrer">http://www.51ti.vip</a>). </p>
  
  <p>Nginx will forward all requests to other backend server. The communication is working on port 80. </p>
  
  <p>However, once proxy_set_header XXXXX is set, it will appear 403 when accessed.
  There is no relevant error information in /var/log/nginx/error.log.</p>
  
  <p>Where's the problem?</p>
  
  <p><strong>Page 403 Forbidden</strong></p>
  
  <p>You don't have permission to access the URL on this server.</p>
  
  <p><strong>Note:</strong></p>
  
  <ul>
  <li>OS System: CentOS 6.9_64</li>
  <li>Nginx version 1.10.2</li>
  </ul>
  
  <p><strong>Config:</strong></p>
  
  <p>/etc/nginx/nginx.conf as follows:</p>
  
  <pre><code>user root;
  worker_processes auto;
  error_log /var/log/nginx/error.log;
  pid /var/run/nginx.pid;
  
   include /usr/share/nginx/modules/*.conf;
  
   events {
     worker_connections  1024;
   }
  
  
   http {
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
  
       access_log  /var/log/nginx/access.log  main;
  
       sendfile            on;
       tcp_nopush          on;
       tcp_nodelay         on;
       keepalive_timeout   65;
       types_hash_max_size 2048;
  
  
       include             /etc/nginx/mime.types;
       default_type        application/octet-stream;
       include /etc/nginx/conf.d/*.conf;
     }
  </code></pre>
  
  <p>/etc/nginx/conf.d/default.conf as follows:</p>
  
  <pre><code>server {
      listen       80 default_server;
      server_name  47.75.249.199 "";
      root         /usr/share/nginx/html;
  
     # Load configuration files for the default server block.
     include /etc/nginx/default.d/*.conf;
  
  
  location / {
      proxy_pass http://sq.otherserver.com;
  
      #Proxy Settings
      proxy_redirect off;
  
      #proxy_set_header Host $host;
      #proxy_set_header X-Real-IP $remote_addr;
      #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  
   error_page 404 /404.html;
      location = /40x.html {
   }
  
   error_page 500 502 503 504 /50x.html;
      location = /50x.html {
   }
  }
  </code></pre>