Reverse Proxy #275
Replies: 6 comments 3 replies
-
Thanks, is this something that can live alongside the default nginx config? Feel free to raise a PR if so, otherwise, I'll include it in the docs. :) |
Beta Was this translation helpful? Give feedback.
-
It could be added to the bottom of the server block in "default.conf" or as a new file named something like "pialert.subfolder.conf" in the "proxy-confs" folder in the SWAG container. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks! Looking at the file: https://github.com/jokob-sk/Pi.Alert/blob/main/install/default Would this be the correct format to preserve the previous functionality? server {
listen 80 default_server;
root /var/www/html;
index index.php;
rewrite /pialert/(.*) / permanent;
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_connect_timeout 75;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
}
}
location /pialert {
return 301 $scheme://$host/pialert/;
}
location ^~ /pialert/ {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app pialert;
set $upstream_port 20211;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_set_header Accept-Encoding "";
proxy_redirect ~^/(.*)$ /pialert/$1;
rewrite ^/pialert/?(.*)$ /$1 break;
sub_filter_once off;
sub_filter_types *;
sub_filter 'href="/' 'href="/pialert/';
sub_filter '(?>$host)/css' '/pialert/css';
sub_filter '(?>$host)/img' '/pialert/img';
sub_filter '(?>$host)/js' '/pialert/js';
sub_filter '(?>$host)/lib' '/pialert/lib';
sub_filter '(?>$host)/php' '/pialert/php';
} |
Beta Was this translation helpful? Give feedback.
-
Oh, I understand the question now. The location blocks would have to go inside the server block. Also /config/nginx/proxy.conf and resolver.conf are part of the SWAG container. But even if those were included, I'm not sure it would work, plus it doesn't really make sense to include them in the app's default nginx config. When used in SWAG (or nginx proxy manager, etc.) it allows Pi.Alert to be accessed with a friendly URL, https://intranet/pialert/ in my case. |
Beta Was this translation helpful? Give feedback.
-
Alright, I'm slowly starting to get it. Can you please write up a step by step guide on how to use the Swag container to setup reverse proxy? I started something here, but I lack sufficient knowledge: https://github.com/jokob-sk/Pi.Alert/blob/main/docs/REVERSE_PROXY.md You can past a comment here and I'll update that doc |
Beta Was this translation helpful? Give feedback.
-
Closing as released / no activity |
Beta Was this translation helpful? Give feedback.
-
I was able to reverse proxy Pi.Alert using LinuxServer's SWAG container.
Just wanted to share in case anyone else if looking to do this.
pialert.subfolder.conf
Beta Was this translation helpful? Give feedback.
All reactions