WebFaction
Community site: login faq

My setup webfactions nginx ==> my nginx ==> app_server(gunicorn) ==> flask

Hi, I am dealing with an issue that is baffling to me. I have recently set everything up, and for the most part it works ok. However, I have two questions that someone more knowledgeable than me can answer.

Question 1: What are the location proxy directives that I should be using, because I can only intermittently get the client ip address. Most of the time it just comes through as 127.0.0.1, the downstream webfaction nginx server.

location @proxy_to_app { proxy_set_header Host $http_host; #proxy_set_header X-Real-IP $remote_addr; proxy_set_header HTTP_X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_redirect default;
        proxy_pass   http://app_server;

}

This is what I currently have. Originally, I used X-Forwarded-For rather than HTTP_X-Forwarded-For, but I read somewhere it should be that. When I changed, I indeed got the external ip, however, after coming back to it an hour later, it has changed back without any changes to my configuration.

Is there a set of downstream load balancers that have different settings? Is that why it is intermittent.

Question 2:

If I click quickly three or four times on various items on the website from my browser, I can quickly overwhelm something, because the url in the browser changes to http://{my appserver}/rest/of/returned/url.

What governs the form of that url? Can someone suggest an area to look at to fix this problem?

asked 09 Feb '12, 20:29

dons
111
accept rate: 0%


Although I have spent quite a few hours on this trying various alternatives and searching around for answers, I stumbled onto an answer shortly after posting this.

It figures.

For those after me who search on this problem: In your flask application,

from werkzeug.contrib.fixers import ProxyFix app.wsgi_app = ProxyFix(app.wsgi_app)

Either that, or it is back to intermittently working again.

permanent link

answered 09 Feb '12, 21:03

dons
111
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×44
×12

question asked: 09 Feb '12, 20:29

question was seen: 4,935 times

last updated: 09 Feb '12, 21:03

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM