0

I'm tring to make many django/gunicorn app on one server. Each app listen on one specific port. My nginx conf is like :

upstream my_app_2318 {
       server unix:/tmp/gunicorn-2318.sock    fail_timeout=10s
}
       server {
           listen                *:2318;
           server_name           example.com;

           index  index.html index.htm index.php;

           access_log            /opt/2318/logs/nginx_access.log combined;
           error_log             /opt/2318/logs/nginx_error.log;

           location / {
               proxy_pass            http://my_app_2318;
               proxy_read_timeout    90;
               proxy_connect_timeout 90;
               proxy_redirect        off;
           }
}

This conf work for GET request (when i acces to example.com:2318/my-url), but any POST request (submit form) redirect me on 80 port (example.com/my-new-url).

What's wrong with my conf ?

Thanks

13
  • Because you wrote proxy_redirect off; Commented Mar 10, 2015 at 9:36
  • When i put proxy_redirect default; i have same problem Commented Mar 10, 2015 at 12:46
  • Check what exactly is in Location header Commented Mar 10, 2015 at 13:21
  • Check your html code, more specifically the action attribute of your form tag. Commented Mar 11, 2015 at 0:41
  • @AlexeyTen how can i check that ? Commented Mar 11, 2015 at 10:19

1 Answer 1

1

I have solution. The problem was in the header location.

I had need to use proxy_redirect header like this.

upstream my_app_2318 {
   server unix:/tmp/gunicorn-2318.sock    fail_timeout=10s
}
   server {
       listen                *:2318;
       server_name           example.com;

       index  index.html index.htm index.php;

       access_log            /opt/2318/logs/nginx_access.log combined;
       error_log             /opt/2318/logs/nginx_error.log;

       location / {
           proxy_pass            http://my_app_2318;
           proxy_redirect        http://example.com/ http://example.com:2318/;
           proxy_read_timeout    90;
           proxy_connect_timeout 90;
       }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.