[GH-ISSUE #158] [QUESTION] Nginx Configuration To Proxy Whoogle as A Subdirectory Cannot Find /config. How to handle this? #115

Closed
opened 2026-02-25 20:34:56 +03:00 by kerem · 7 comments
Owner

Originally created by @Saroufim on GitHub (Dec 11, 2020).
Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/158

Hello,
I'm running Whoogle as a subfolder on my site under /search/. At first, Whoogle wouldn't find its static files but then I explicitly used sub_filter to redirect it to the right path. Now Whoogle won't read its own configs from the same path and reverts back to looking for them on the main site, ignoring the sub_filter rule. What is the proper way to handle this with nginx?

Here's my conf:


location /search/   {
    include /config/nginx/proxy.conf
    sub_filter_once off;
    sub_filter '/static/' '/search/static/';
    sub_filter_types *;
    sub_filter "/config" "/search/config";
    proxy_pass http://0.0.0.0:5000/;
}

Originally created by @Saroufim on GitHub (Dec 11, 2020). Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/158 Hello, I'm running Whoogle as a subfolder on my site under /search/. At first, Whoogle wouldn't find its static files but then I explicitly used sub_filter to redirect it to the right path. Now Whoogle won't read its own configs from the same path and reverts back to looking for them on the main site, ignoring the sub_filter rule. What is the proper way to handle this with nginx? Here's my conf: ``` location /search/ { include /config/nginx/proxy.conf sub_filter_once off; sub_filter '/static/' '/search/static/'; sub_filter_types *; sub_filter "/config" "/search/config"; proxy_pass http://0.0.0.0:5000/; } ```
kerem 2026-02-25 20:34:56 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@somebody-somewhere-over-the-rainbow commented on GitHub (Jan 23, 2021):

Not running whoogle on a subfolder myself but have you tried to add a rewrite like this to the location block:

rewrite ^/search/(.*)$ /$1 break;

<!-- gh-comment-id:766175137 --> @somebody-somewhere-over-the-rainbow commented on GitHub (Jan 23, 2021): Not running whoogle on a subfolder myself but have you tried to add a rewrite like this to the location block: ` rewrite ^/search/(.*)$ /$1 break;`
Author
Owner

@maaAnandsheela commented on GitHub (Jan 30, 2021):

    location /search {
           rewrite /search/(.*) /$1 break;
           proxy_pass http://0.0.0.0:5000/;
           proxy_redirect     off;
            proxy_set_header Host $host;
           proxy_http_version 1.1;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    

}

This should work.

<!-- gh-comment-id:770188739 --> @maaAnandsheela commented on GitHub (Jan 30, 2021): location /search { rewrite /search/(.*) /$1 break; proxy_pass http://0.0.0.0:5000/; proxy_redirect off; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } This should work.
Author
Owner

@somebody-somewhere-over-the-rainbow commented on GitHub (Jan 30, 2021):

it tried this just for fun and it given (at least) me a white, empty page

<!-- gh-comment-id:770263191 --> @somebody-somewhere-over-the-rainbow commented on GitHub (Jan 30, 2021): it tried this just for fun and it given (at least) me a white, empty page
Author
Owner

@maaAnandsheela commented on GitHub (Feb 4, 2021):

maybe there should be some error.

<!-- gh-comment-id:773464304 --> @maaAnandsheela commented on GitHub (Feb 4, 2021): maybe there should be some error.
Author
Owner

@looi-wh commented on GitHub (Jun 22, 2021):

hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself

location /google {
    return 302 $scheme://$host/google/;
}
location /google/ {
    sub_filter_once off;
    sub_filter 'https://domain.com' 'https://domain.com/google/';
    proxy_pass http://0.0.0.0:5000/;
}
<!-- gh-comment-id:866125870 --> @looi-wh commented on GitHub (Jun 22, 2021): hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself ``` location /google { return 302 $scheme://$host/google/; } location /google/ { sub_filter_once off; sub_filter 'https://domain.com' 'https://domain.com/google/'; proxy_pass http://0.0.0.0:5000/; } ```
Author
Owner

@cs01 commented on GitHub (Sep 1, 2021):

hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself

location /google {
    return 302 $scheme://$host/google/;
}
location /google/ {
    sub_filter_once off;
    sub_filter 'https://domain.com' 'https://domain.com/google/';
    proxy_pass http://0.0.0.0:5000/;
}

I spent more time than I want to admit trying to solve this. I thought WHOOGLE_CONFIG_URL might work but it didn't, but the above worked perfectly.

It might be helpful to others to add the above config to the README since it's probably a fairly common setup.

<!-- gh-comment-id:909911893 --> @cs01 commented on GitHub (Sep 1, 2021): > hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself > > ``` > location /google { > return 302 $scheme://$host/google/; > } > location /google/ { > sub_filter_once off; > sub_filter 'https://domain.com' 'https://domain.com/google/'; > proxy_pass http://0.0.0.0:5000/; > } > ``` I spent more time than I want to admit trying to solve this. I thought `WHOOGLE_CONFIG_URL` might work but it didn't, but the above worked perfectly. It might be helpful to others to add the above config to the README since it's probably a fairly common setup.
Author
Owner

@caio1007 commented on GitHub (Mar 5, 2023):

hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself

location /google {
    return 302 $scheme://$host/google/;
}
location /google/ {
    sub_filter_once off;
    sub_filter 'https://domain.com' 'https://domain.com/google/';
    proxy_pass http://0.0.0.0:5000/;
}

this code is giving me an error in nginx

<!-- gh-comment-id:1455106862 --> @caio1007 commented on GitHub (Mar 5, 2023): > hi. tho its abit late, but I have solved this issue somehow as i was setting up whoogle for myself > > ``` > location /google { > return 302 $scheme://$host/google/; > } > location /google/ { > sub_filter_once off; > sub_filter 'https://domain.com' 'https://domain.com/google/'; > proxy_pass http://0.0.0.0:5000/; > } > ``` this code is giving me an error in nginx
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whoogle-search#115
No description provided.