Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8733365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:38:05+00:00 2026-06-13T09:38:05+00:00

I have a django application running on http://localhost:12345 . I’d like user to access

  • 0

I have a django application running on http://localhost:12345 .
I’d like user to access it via url http://my.server.com/myapp .
I use nginx to reverse proxy to it like the following:

... ...
server_name my.server.com;
location /myapp {
    rewrite /myapp(.*) $1 break;        
    ... ... # proxy param 
    proxy_pass http://localhost:12345;
}
... ...

The question is, when configured like the above, how to make the urls in my response pages to have a prefix of “/myapp” so that the nginx can direct them correctly to myapp. E.g., the urls in a page like “/foo/far” ought to be changed to “/myapp/foo/bar” to allow nginx proxy to myapp.
what is the right nginx configure to use to achieve this ?

I can use settings variables of django to specify the root url prefix, but it’s not flexiable to my mind, since the variable have to be modified according to different nginx configuration(say one day nginx may change the suburl from “/myapp” to “/anotherapp”).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:38:07+00:00Added an answer on June 13, 2026 at 9:38 am

    As the prefix is set in Nginx, the web server that hosts the Django app has no way of knowing the URL prefix. As orzel said, if you used apache+mod_wsgi of even nginx+gunicorn/uwsgi (with some additional configuration), you could use the WSGIScriptAlias value, that is automatically read by Django.

    When I need to use a URL prefix, I generally put it myself in my root urls.py, where I have only one line, prefixed by the prefix and including an other urls.py

    (r'^/myapp/', include('myapp.urls')),
    

    But I guess this has the same bottleneck than setting a prefix in settings.py, you have redundant configuration in nginx and Django.

    You need to do something in the server that hosts your Django app at :12345. You could set the prefix there, and pass it to Django using the WSGIScriptAlias or its equivalent outside mod_wsgi. I cannot give more information as I don’t know how your Django application is run. Also, maybe you should consider running your Django app directly from Django, using uWSGI or gunicorn.

    To pass the prefix to Django from the webserver, you can use this :

    proxy_set_header SCRIPT_NAME /myapp;
    

    More information here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django application running locally and I'd like to test the send_mail()
I have a Django application which resets unix user passwords running in an Ubuntu
I have an application running on Django. I'd like to be able to authenticate/authorize
I have a django web application running on our apache2 production server using mod_python
I have a Gunicorn server running a Django application which has a tendency to
I have a django application running under twisted. I have server.py with the following
I have a django application hosted on a server running on Apache + Ubuntu.
HI I have a django application running on app engine and I want to
I have a Django applciation running on Apache with mod_wsgi, but I would like
I have been trying to integrate Google calendar into a Django application running on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.