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 9259479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:40:04+00:00 2026-06-18T12:40:04+00:00

I am running an nginx (0.7.67) as a reverse proxy and a golang application.

  • 0

I am running an nginx (0.7.67) as a reverse proxy and a golang application. The nginx server is configured as follows:

...
location /bar/ {
  proxy_pass http://localhost:8088/;
  proxy_redirect off;
  proxy_set_header  Host               $host;
  proxy_set_header  X-Real-IP          $remote_addr;
  proxy_set_header  X-Forwarded-For    $proxy_add_x_forwarded_for;
  proxy_set_header  X-Forwarded-Proto  https;
}
...

The source of my golang application (it doesn’t make sense, only an example):

func root(w http.ResponseWriter, r *http.Request) {
  fmt.Fprint(w, "You reached root")
}

func foo(w http.ResponseWriter, r *http.Request) {
  http.Redirect(w, r, "/", http.StatusFound)
}

func main() {
  http.HandleFunc("/", root)
  http.HandleFunc("/foo", foo)
  http.ListenAndServe("localhost:8088", nil)
}

Problem: When I direct my browser to the URL of my application (https://domain.tld/bar/) I can see the text “You reached root”. However, if I try to open https://domain.tld/bar/foo, I get redirected to https://domain.tld instead of https://domain.tld/bar. It seems that my application is redirecting to the root of the nginx server and not the application.

Question: How can I redirect from the inside of my application (running behind an nginx reverse proxy) to the root of my application, instead of the root of the server?

  • 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-18T12:40:05+00:00Added an answer on June 18, 2026 at 12:40 pm

    This is a problem that cannot be solved automatically in any language, even PHP. What applications such as wordpress do is have a setting to specify the root. Some applications require a full url (https://domain.tld/bar) or can just have a path (/bar).

    Either way, you need to create a setting and then manually configure all redirects to be based from there. You can create your own redirect function so you don’t need to implement it each time you do a redirect.

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

Sidebar

Related Questions

i am running apache server with nginx as reverse proxy on ubuntu 10LTS .
I have a django application running on http://localhost:12345 . I'd like user to access
I am running a Django-based webservice with Gunicorn behind nginx as a reverse proxy.
i would like to replace my node-http-proxy module with nginx proxy_pass module. Is it
We are running nginx as a reverse proxy that forwards requests to a Clojure
Currently I have a home server (Ubuntu) with nginx running where I use proxy
I am running nginx as reverse proxy for the site example.com to loadbalance a
I have several apps running behind an Nginx reverse proxy, one of which is
I have two websites running on my own root server (ubuntu/nginx/php-fpm). Now I want
I have installed Nginx 1.2.0 with Passenger on my Mac Mini running Lion Server.

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.