skip to Main Content

I have this simple redirect from ‘/’ to ‘/home’, handled by flask with

app.py

@app.route('/') #Redirects to home page
def redirect_home():
    return redirect("/home")

When I use it with my browser it always leads a connection timeout error, althoug when using cURL on my vps (with -L) it does lead to the webpage correctly

I believe it has to do with my nginx setup:
sites-available

location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }

I used to face this issue before on my old vps and I remember fixing it by adding something to the nginx configuration but I don’t remember what it was

2

Answers


  1. Chosen as BEST ANSWER

    The issue was solved by simply allowing HTTP traffic through nginx using the command:enter code here

    ufw allow 'Nginx HTTP'

    I am confused by how thats what fixed it but it really did work after that Although im not sure why it only afftected redirecting


  2. Try

    @app.route('/', methods=['GET']) #Redirects to home page
    def redirect_home():
        return redirect("/home"), 301
    

    Add the request error if not solved..

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search