Home  >  Q&A  >  body text

nginx reverse proxy uses multiple location URLs to match different services on different hosts, resulting in a 404 problem.

There are two existing service application addresses:
192.168.5.20:5080 jenkins
192.168.5.20:2080 gitlab

I want to deploy nginx reverse proxy on 192.168.0.161 (another machine) and configure two locations, pointing to the above two addresses respectively, but a 404 error always occurs.

Configuration as follows:

Phenomena:
When accessing: 192.168.5.161/jenkins from the browser:
The browser address bar changes to: 192.168.5.161/login?from=%2F
The page displays 404

Purpose:
When accessing 192.168.5.161/jenkins, the browser URL address remains unchanged, and the page is forwarded to 192.168.5.20:5080, which is the service where Jenkins is located. How do I change the configuration?

为情所困为情所困2714 days ago1024

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 17:12:20

    If your Jenkins/GitLab does not support configuring to add something to the URL path, then don’t try this again. nginx can do redirect rewriting, but there may also be absolute path links in the web page. Even if you rewrite the web page, the web page may still be constructed into wrong links through JavaScript.

    You can configure two domain names (vhosts) to provide different services.

    reply
    0
  • Cancelreply