evan-buss / openbooks

Search and Download eBooks
https://evan-buss.github.io/openbooks/
MIT License
1.79k stars 59 forks source link

Base URL #26

Open samcro1967 opened 3 years ago

samcro1967 commented 3 years ago

Is there a way to have it listen on http://ip:port/baseurl instead of http://ip:port for putting behind a reverse proxy?

sbelongie commented 2 years ago

would like to have this as well. When using a reverse proxy I am getting this

2021/07/22 07:43:28 websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

sbelongie commented 2 years ago

I got this working with turning on websockets,Asset Caching,and HSTS in my config. @samcro1967

example config

------------------------------------------------------------

subdomain.domain.com

------------------------------------------------------------

server { set $forward_scheme http; set $server "192.168.1.x"; set $port 8181;

listen 8080; listen [::]:8080;

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

server_name subdomain.domain.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-37/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/npm-37/privkey.pem;

Asset Caching

include conf.d/include/assets.conf;

HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)

add_header Strict-Transport-Security "max-age=63072000; preload" always;

Force SSL

include conf.d/include/force-ssl.conf;

proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_http_version 1.1;

access_log /data/logs/proxy_host-15.log proxy;

location / {

HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)

add_header Strict-Transport-Security "max-age=63072000; preload" always;    
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;

# Proxy!
include conf.d/include/proxy.conf;

}

Custom

include /data/nginx/custom/server_proxy[.]conf; }

samcro1967 commented 2 years ago

Glad you got it working. I am using Caddy instead of nginx, but it may help others down the road.

samcro1967 commented 2 years ago

@evan-buss Is this something you can add to a future releaae?

evan-buss commented 2 years ago

@samcro1967 @sbelongie

I've added application support for specifying the base path. Please try it out and let me know if you have any issues. You may have to adjust your reverse proxy settings, but they should be a lot simpler.

Instructions

samcro1967 commented 2 years ago

Works perfectly. Thanks!

samcro1967 commented 2 years ago

This seems to have stopped working since the last update.

evan-buss commented 2 years ago

Hmm. I will take a look. Thanks for reporting!

samcro1967 commented 2 years ago

A little more testing and what I found...

I was only serving this up with caddy externally. I setup caddy to serve it internally and it works as expected. Externally it seems to work with Edge, but not Chrome. Externally in Chrome, sometimes I get page not found, other times I get a partially loaded page (screen shot below). Clearing Chrome cache got me a little further, but it still does not load the same in Chrome externally as it does internally or with Edge externally. I also tried private mode in both Edge and Chrome. They both work internally, but neither works externally.

Externally before clearing Chrome Cache image

Externally after clearing Chrome cache image

How it looks in Edge externally image

anoosa1 commented 2 years ago

when i put mine is baseurl https://domain.com/services/openbooks i get a 404 error

Albrod commented 2 years ago

I have it working with npm as proxy host

Add proxy host, set up domain names Scheme http forward to container name or ip port 80 Set Websockets Support on

Add custom locations / forward to ip or container name/openbooks/ port 80 add these on the cogwheel

add_header Strict-Transport-Security "max-age=63072000; preload" always; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection;

Set up SSL with all things enabled And last on Advanced add_header Strict-Transport-Security "max-age=63072000; preload" always;

With all of that i made it work perfectly behind nginx proxy manager