Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Hi I am used to working with Apache and Mod proxy where I my server configuration looks a bit like this and I redirect all incoming requests from



  ServerName example.com
  DocumentRoot /var/www/trunk/public



  ServerName www.example.com
  Redirect permanent / http://mentoredge.com



    ProxyPreserveHost On
    ServerName o.example.com
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/


Here I route all my incoming request on o.example.com to port 8000 of localhost.

I have migrated to Nginx now im trying to setup this proxy for the same o.example.com. Could somebody explain to me how to get this done.

 
server {
  listen 80;

  server_name o.example.com;

  location / {
       proxy_pass http://localhost:8000;
       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;
       client_max_body_size    10m;
       client_body_buffer_size 128k;
       proxy_connect_timeout   90;
       proxy_send_timeout      90;
       proxy_read_timeout      90;
       proxy_buffers           32 4k;
       proxy_set_header X-Forwarded-Server $host;

  }

}

This is what I have added to my conf but this does not seem to do what I expect it do. Am I missing something here. The thing is I store it as a separate .conf file and it gets added first before all other server information.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Here is what I use

            location / {
                    proxy_read_timeout 2000;
                    proxy_next_upstream error;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Host $http_host;
                    proxy_redirect off;
                    proxy_max_temp_file_size 0;
                    proxy_pass http://localhost:8000;
                    break;

            }
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.