Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
How to properly use locations in Nginx

I have 2 APIs (one built with Flask and the other one with FastAPI):

-- home
   -- app_flask
          main_flask.py
   -- app_fastapi
          main_fastapy.py

I defined a get endpoint in both files:

main_flask.py

from flask import Flask
app = Flask(__name__)

@app.route("/hello_flask")
def hello():
    return {"result": "Welcome to Flask"}

main_fastapi.py

from fastapi import FastAPI
app = FastAPI()

@app.get("/hello_fastapi")
def hello():
    return {"result": "Welcome to FastAPI"}

The first one runs on port 8000 and the second one on port 8001

This is my /etc/nginx/sites-enabled/default file:

server {
    listen 80;
    server_name {here_my_IP};
    location /flask_app {
        proxy_pass http://127.0.0.1:8000;
    }

    location /fastapi_app {
        proxy_pass http://127.0.0.1:8001;
    }
}

But once everything is running, when I access to

http://myIP/flask_app/hello_flask

or

http://myIP/fastapi_app/hello_fastapi

I get this error:

{"error":["404 - Resource Not Found"]}

I don't get this error if I use location / {} instead of location /app {} on the default Nginx file and then I access to

http://myIP/hello_fastapi (for example in the case of the first API)

So I conclude that I am incorrectly routing the apps on the defaul configuration Nginx file.

How should I do it?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda