0

I have deployed a simple Django application in the AWS server and created a config file in the Nginx as follows.

                 server {
                         listen 80;
                         server_name 127.0.0.1;
                         location /portal {
                         include proxy_params;
                         proxy_pass http://localhost:8000;
                           }
                        }

But it is not working and showing as "404 not found".

Django application alone working in a URL as http://public_ip/en/ but I need to serve this application in http://public_ip/portal.

aks
  • 37
  • 1
  • 6

1 Answers1

0

When configured this way, nginx appends the string /portal at the end of proxy_pass location, that is, your application receives URL http://localhost:8000/portal when you request http://public_ip/portal.

In order for /portal requests to reach /en, you need to use:

location /portal {
    include proxy_params;
    proxy_pass http://localhost:8000/en;
}
Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • Thank you. It worked – aks Feb 09 '21 at 06:37
  • how can I add my static folder for the above config file? Currently, this file not detecting my static folder – aks Feb 11 '21 at 17:02
  • That is a separate question, please create a new question with the details of your configuration and file locations. – Tero Kilkanen Feb 11 '21 at 20:08
  • Added my new question: https://serverfault.com/questions/1053367/how-to-point-static-folder-in-nginx-for-a-django-application – aks Feb 12 '21 at 06:17