-
-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support reverse proxy with path rewrite #127
Conversation
The nginx configuration I used to test this: events {}
http {
server {
listen 127.0.0.1:10001;
location /gotify/ {
rewrite ^/gotify/(.*) /$1 break;
proxy_pass http://127.0.0.1:10000$uri$is_args$args;
}
location /gotify/stream {
rewrite ^/gotify/(.*) /$1 break;
proxy_pass http://127.0.0.1:10000$uri$is_args$args;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, there are still some things todo.
The images for applications aren't properly mapped. (See api/application.go:323).
Loading the Swagger UI on the proxy can't load the swagger definition. (http://localhost:8080/gotify/docs)
If the swagger definition is loaded, then it will probably still not work, because no basepath is set inside the definition.
Having a trailing slash at the end redirects wrongly.
http://localhost:8080/gotify/docs/
-> http://localhost:8080/docs
I've used the following config with Caddy:
localhost:8080
proxy /gotify localhost:80 {
without /gotify
transparent
}
proxy /gotify/stream localhost:80 {
without /gotify
websocket
transparent
}
I think this is an existing issue because I found that even on my deployment without a reverse proxy I need to manually enter the spec URL to get the swagger definitions. |
Codecov Report
@@ Coverage Diff @@
## master #127 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 39 39
Lines 1400 1400
=====================================
Hits 1400 1400 Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #127 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 39 39
Lines 1400 1400
=====================================
Hits 1400 1400
Continue to review full report at Codecov.
|
I induced an API change that application image URLs are no longer resolved to absolute ones. Resolving URIs relative to the gotify path should be handled by the front-end, not back-end. For the trailing slash problem I changed my events {}
http {
server {
listen 127.0.0.1:10001;
location = /gotify {
return 301 /gotify/;
}
location /gotify/ {
rewrite ^/gotify/(.*) /$1 break;
proxy_pass http://127.0.0.1:10000$uri$is_args$args;
proxy_redirect ~^/(.*)$ /gotify/$1;
}
location /gotify/stream {
rewrite ^/gotify/(.*) /$1 break;
proxy_pass http://127.0.0.1:10000$uri$is_args$args;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
} For caddy config I guess it should be something like this(I am not very familiar with that, I just translated it from the nginx config and I havn't tested this extensively) localhost:10001
redir /gotify /gotify/
proxy /gotify/ localhost:10000 {
without /gotify/
transparent
header_downstream -Location
}
proxy /gotify/stream localhost:10000 {
without /gotify
websocket
transparent
} |
9a283ed
to
864ca64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing how the images get returned breaks the api and would require an increment of the major version. (It also breaks the images in gotify/android). Tho' I can't think of an other way if we want to support path rewriting with a proxy.
This also breaks images in gotify/android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll use GitHub "squash" this time.
This fixes #122.
Changed the home path so that the page loads static assets relative to the page URL.
Also changed how API path is parsed so that the base path is considered.