Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
Solicitud de reenvío de Nginx a otro puerto

estoy usando fastapi , gunicorn y nginx en mi servidor

Mi aplicación web main.py es

 from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: str = None): return {"item_id": item_id, "q": q}

Ejecuto el código anterior para escuchar dos puertos 8080 y 8081

 gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8080" --log-level debug main:app gunicorn -k uvicorn.workers.UvicornWorker --bind "0.0.0.0:8081" --log-level debug main:app

Luego en mi nginx.conf

 server { listen 80 default_server; listen [::]:80 default_server; server_name 127.0.0.1; root /usr/share/nginx/html; include /etc/nginx/default.d/*.conf; location / { proxy_pass http://127.0.0.1:8080/; } location /another { proxy_pass http://127.0.0.1:8081/; } }

Espero los resultados como a continuación

 xxx.xxx.xxx.xxx/ => {"Hello":"World"} xxx.xxx.xxx.xxx/items/1 => {"item_id":1,q:null} xxx.xxx.xxx.xxx/another => {"Hello":"World"} xxx.xxx.xxx.xxx/another/items/1 => {"item_id":1,q:null}

pero lo consigo

 xxx.xxx.xxx.xxx/ => {"Hello":"World"} xxx.xxx.xxx.xxx/items/1 => {"item_id":1,q:null} xxx.xxx.xxx.xxx/another => {"Hello":"World"} xxx.xxx.xxx.xxx/another/items/1 => {"Detail": "Not Found"} // Here is the problem

¿Cómo puedo reenviar la solicitud como espero?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!