OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • Help with Nginx proxy rewrite rule
« previous next »
  • Print
Pages: [1]

Author Topic: Help with Nginx proxy rewrite rule  (Read 2465 times)

lenovo

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Help with Nginx proxy rewrite rule
« on: August 08, 2022, 11:06:33 am »
I use OPNsense Nginx as a proxy for a webserver.
The webserver has a site in a folder (myfolder) in the html root: /var/www/html/myfolder
This all works as expected. When I use a browser it shows https://mywebsite.com/myfolder in the address bar.
Now I'm trying to only rewrite the url with Nginx so the browser will show https://mywebsite.com but NOT redirect.
This is the OPNsense-Nginx config I tried:

Original URL Pattern (Regex): ^.*$
New URL Pattern:  https://mywebsite.com
Flag: (tried all options)

In location this rule is selected.
The result works (address bar only shows https://mywebsite.com), but browser errors with too many redirects.

Newbie here with Nginx and Regex, so I expect I'm doing something stupid.
Can some kind soul enlighten me and show me the right Regex syntax / Nginx url rewrite config?
   
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1777
  • Karma: 164
    • View Profile
Re: Help with Nginx proxy rewrite rule
« Reply #1 on: August 20, 2022, 09:37:41 am »
imho url rewrite is not needed in this case
you can try to add  "/myfolder/" Path Prefix in "/" location settings
Logged

lenovo

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Help with Nginx proxy rewrite rule
« Reply #2 on: August 20, 2022, 06:58:41 pm »
Thanks for your reply and help!
This did not work. /myfolder gave a page not found and /myfolder/ gave an index listing.
However, what I failed to mention is that I am searching for a solution for the url to always stay the same in the browser (https://mywebsite.com), whatever folder is used bij the target webserver.
So A solution which works with more then one specific folder 
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1777
  • Karma: 164
    • View Profile
Re: Help with Nginx proxy rewrite rule
« Reply #3 on: August 20, 2022, 07:22:30 pm »
then i don't understand your end goal and/or backend settings, sorry..
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • Help with Nginx proxy rewrite rule
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2