Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda