Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Apache reverse proxy setup with subpath (http://myhost.xx/searx) #1819

Closed
return42 opened this issue Jan 30, 2020 · 3 comments
Closed

Apache reverse proxy setup with subpath (http://myhost.xx/searx) #1819

return42 opened this issue Jan 30, 2020 · 3 comments

Comments

@return42
Copy link
Contributor

return42 commented Jan 30, 2020

I have setup searx as uwsgi service at http = 127.0.0.1:8888 and a apache mod_proxy with ProxyPath to a filtron service listening on 127.0.0.1:4004 (target is searx at port :8888).

The setup works fine when I use the root URL as public URL http://myhost.xx/:

ProxyPass "/" "http://127.0.0.1:4004/"
ProxyPassReverse "/" "http://127.0.0.1:4004/"

Now I want to move my searx instance to a subpath in the public URL, e.g. http://myhost.xx/searx:

ProxyPass "/searx" "http://127.0.0.1:4004/"
ProxyPassReverse "/searx" "http://127.0.0.1:4004/"

With I got a pure "HTML page" which tries to load resource relative from root URL / instead from /searx/

I read this article https://blog.macuyiko.com/post/2016/fixing-flask-url_for-when-behind-mod_proxy.html and I found similar in our sources 6ef7c32 so I tried also:

ProxyPass "/searx" "http://127.0.0.1:4004/"
ProxyPassReverse "/searx" "http://myhost.xx/searx"

But this does not change anything, the HTML page from searx always try to load resources from the root URL. .. where is my mistake?

@unixfox
Copy link
Member

unixfox commented Jan 30, 2020

Why would you want to do that? I mean nowadays SSL/TLS certificates are free even for subdomains. There is no real reason to serve another service in a subpath.

@return42
Copy link
Contributor Author

@unixfox sorry if I was not clear I was asking about ProxyPass and subpath .. I have found my mistake and will post the solution ..

@return42
Copy link
Contributor Author

return42 commented Jan 30, 2020

I forgot to set request header X-Script-Name here is my final apache site

Updated: Jan, 31 2020 ...

ProxyPreserveHost On

<Location /searx >

    Require all granted
    Order deny,allow
    Deny from all
    #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
    Allow from all

    ProxyPass http://127.0.0.1:4004
    RequestHeader set X-Script-Name /searx

    # In Apache it seems, that setting HTTP_HOST header direct here does have no
    # effect.  I needed to set 'ProxyPreserveHost On' (see above).  HTTP_HOST is
    # needed by searx to render correct *Search URL* in the *Link* box and
    # *saved preference*.

    # RequestHeader set Host myhost.xx

</Location>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants