Hello,
I am setting up a Seafile instance to run through the nginx plugin in OPNSense. Seafile provides an example nginx conf (https://manual.seafile.com/deploy/deploy_with_nginx/#configuring-nginx) to emulate, but I am having trouble getting it right using the OPNSense UI and was wondering if someone could help. The example conf looks like this:
log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';
server {
listen 80;
server_name seafile.example.com;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;
# used for view/edit office file via Office Online Server
client_max_body_size 0;
access_log /var/log/nginx/seahub.access.log seafileformat;
error_log /var/log/nginx/seahub.error.log;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
access_log /var/log/nginx/seafhttp.access.log seafileformat;
error_log /var/log/nginx/seafhttp.error.log;
}
location /media {
root /opt/seafile/seafile-server-latest/seahub;
}
}
Specifically I am unsure about how to implement the "proxy_pass" in "location" "/seafhttp":
(https://i.ibb.co/kgq88TH/image.png)
I already have an "upstream" and "upstream server" defined for port 8000 to satisfy the first "location":
(https://i.ibb.co/Yy1Vfbx/image.png)
(https://i.ibb.co/gd8xxzh/image.png)
Should I create a second "upstream" and "upstream server" to handle port 8082?
(https://i.ibb.co/Zd2pF4h/image.png)
Do I then add a "location" for it:
(https://i.ibb.co/SdfTjB9/image.png)
And associate that location with the existing "HTTP Server" already created:
(https://i.ibb.co/1vs7Pqq/image.png)
Or perhaps create a separate "HTTP Server" for it?
I also have a question about the "rewrite" code:
(https://i.ibb.co/dgpLWyj/image.png) (https://ibb.co/sH16mrb)
I created the following "URL Rewrite":
(https://i.ibb.co/HNY7RBR/opn-sense-forum-url-rewrite.jpg)
Then I selected it in both, the "HTTP Server", and the "Location" for "/seafhttp" - is that right?
Thanks for any help on part or all of this.
Hi!
opnsense nginx plugin uses upstream module to pass requests (https://nginx.org/en/docs/http/ngx_http_upstream_module.html), therefore it is not possible to get an exact replica of the example config - part of the parameters will be determined in the upstream context.
QuoteShould I create a second "upstream" and "upstream server" to handle port 8082?
yes
QuoteDo I then add a "location" for it:
yes
QuoteAnd associate that location with the existing "HTTP Server" already created
yess
QuoteOr perhaps create
no ;)
QuoteI created the following "URL Rewrite
looks fine
QuoteThen I selected it in both, the "HTTP Server", and the "Location" for "/seafhttp" - is that right?
should be added to Location only
Thanks a lot for your helpful response! Should the second location look like this:
(https://i.ibb.co/jThDr8Y/image.png)