[GH-ISSUE #304] Nginx Reverse Proxy - Unable To Change View #201

Closed
opened 2026-03-02 11:47:34 +03:00 by kerem · 3 comments
Owner

Originally created by @Majoraslayer on GitHub (Jul 13, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/304

I have my instance of Hoarder hosted through an Nginx reverse proxy config. If I access Hoarder locally at it's 3000 port, everything works fine. However, if I access it through my external site address, I'm unable to change the view from Masonry to Grid or List. Is there a suggested Nginx config available? I'm probably missing an option it needs or something. Here's a sample of my config, with private details changed to examples:

server {
        listen         443 ssl http2;
        server_name    notes.mydomain.exa;
        location / {
          proxy_pass http://192.168.1.40:3000;
          client_max_body_size 800M;
        }
        # [Insert my Certbot certificates here]
}
Originally created by @Majoraslayer on GitHub (Jul 13, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/304 I have my instance of Hoarder hosted through an Nginx reverse proxy config. If I access Hoarder locally at it's 3000 port, everything works fine. However, if I access it through my external site address, I'm unable to change the view from Masonry to Grid or List. Is there a suggested Nginx config available? I'm probably missing an option it needs or something. Here's a sample of my config, with private details changed to examples: ``` server { listen 443 ssl http2; server_name notes.mydomain.exa; location / { proxy_pass http://192.168.1.40:3000; client_max_body_size 800M; } # [Insert my Certbot certificates here] } ```
kerem closed this issue 2026-03-02 11:47:34 +03:00
Author
Owner

@kamtschatka commented on GitHub (Jul 14, 2024):

I am using Nginx Proxy Manager and that worked out of the box.
Note: Grid and Masonry look pretty much the same for me, but List layout is different.

I created everything in the Nginx Proxy Manager UI, but this is the config for nginx that was generated(I am using port 4443 for nginx proxy manager):

server {
  set $forward_scheme http;
  set $server         "<internal ip address>";
  set $port           4000;

  listen 8080;
  listen [::]:8080;

  listen 4443 ssl;
  listen [::]:4443 ssl;

  server_name hoarder.<mydomain.com>;

  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-26/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-26/privkey.pem;

  # Force SSL
  include conf.d/include/force-ssl.conf;

  access_log /config/log/proxy-host-13_access.log proxy;
  error_log /config/log/proxy-host-13_error.log warn;
  
  location / {
    # Proxy!
    include conf.d/include/proxy.conf;
  }
}

force-ssl.conf:

set $test "";
if ($scheme = "http") {
        set $test "H";
}
if ($request_uri = /.well-known/acme-challenge/test-challenge) {
        set $test "${test}T";
}
if ($test = H) {
        return 301 https://$host$request_uri;
}

Proxy.conf:

add_header       X-Served-By $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto  $scheme;
proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP          $remote_addr;
proxy_pass       $forward_scheme://$server:$port$request_uri;
<!-- gh-comment-id:2227319434 --> @kamtschatka commented on GitHub (Jul 14, 2024): I am using Nginx Proxy Manager and that worked out of the box. Note: Grid and Masonry look pretty much the same for me, but List layout is different. I created everything in the Nginx Proxy Manager UI, but this is the config for nginx that was generated(I am using port 4443 for nginx proxy manager): ``` server { set $forward_scheme http; set $server "<internal ip address>"; set $port 4000; listen 8080; listen [::]:8080; listen 4443 ssl; listen [::]:4443 ssl; server_name hoarder.<mydomain.com>; # Let's Encrypt SSL include conf.d/include/letsencrypt-acme-challenge.conf; include conf.d/include/ssl-ciphers.conf; ssl_certificate /etc/letsencrypt/live/npm-26/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/npm-26/privkey.pem; # Force SSL include conf.d/include/force-ssl.conf; access_log /config/log/proxy-host-13_access.log proxy; error_log /config/log/proxy-host-13_error.log warn; location / { # Proxy! include conf.d/include/proxy.conf; } } ``` force-ssl.conf: ``` set $test ""; if ($scheme = "http") { set $test "H"; } if ($request_uri = /.well-known/acme-challenge/test-challenge) { set $test "${test}T"; } if ($test = H) { return 301 https://$host$request_uri; } ``` Proxy.conf: ``` add_header X-Served-By $host; proxy_set_header Host $host; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass $forward_scheme://$server:$port$request_uri; ```
Author
Owner

@MohamedBassem commented on GitHub (Jul 14, 2024):

Layouts are controlled by a cookie in the browser attached to the domain you're using hoarder from. So if changing them doesn't do anything it means that the cookies are not correctly propagated to your server or that it's getting ignored by the server for some reason.
A quick google search suggests that forwarding the real hostname to the server might help. Maybe try adding:

proxy_set_header Host $host;

to your nginx config?

<!-- gh-comment-id:2227325033 --> @MohamedBassem commented on GitHub (Jul 14, 2024): Layouts are controlled by a cookie in the browser attached to the domain you're using hoarder from. So if changing them doesn't do anything it means that the cookies are not correctly propagated to your server or that it's getting ignored by the server for some reason. A quick google search suggests that forwarding the real hostname to the server might help. Maybe try adding: ``` proxy_set_header Host $host; ``` to your nginx config?
Author
Owner

@Majoraslayer commented on GitHub (Jul 14, 2024):

Layouts are controlled by a cookie in the browser attached to the domain you're using hoarder from. So if changing them doesn't do anything it means that the cookies are not correctly propagated to your server or that it's getting ignored by the server for some reason. A quick google search suggests that forwarding the real hostname to the server might help. Maybe try adding:

proxy_set_header Host $host;

to your nginx config?

That seems to have done the trick, thanks!

<!-- gh-comment-id:2227385238 --> @Majoraslayer commented on GitHub (Jul 14, 2024): > Layouts are controlled by a cookie in the browser attached to the domain you're using hoarder from. So if changing them doesn't do anything it means that the cookies are not correctly propagated to your server or that it's getting ignored by the server for some reason. A quick google search suggests that forwarding the real hostname to the server might help. Maybe try adding: > > ``` > proxy_set_header Host $host; > ``` > > to your nginx config? That seems to have done the trick, thanks!
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/karakeep#201
No description provided.