Open CounterPillow opened 5 years ago
I'm trying to do the same. You can get far with sub_filter
:
location /wiki/ {
sub_filter 'action="/' 'action="/wiki/';
sub_filter 'href="/' 'href="/wiki/';
sub_filter 'src="/' 'src="/wiki/';
sub_filter_last_modified on;
sub_filter_once off;
..
}
.. but I can't get some of the magical links, like _edit
, to work.
I may have found a workaround (gitit nginx remote proxy to subfolder). With the subfolder as 'gitit' , rewrite to the subfolder via try_files before failing (see below). This assumes a gitit process is serving on localhost:5001. Not pretty but works so far for me.
location @rewrite {
rewrite ^/(.*) $scheme://$host:$server_port/gitit/$1 redirect;
}
location / {
if ($http_referer = "$scheme://$host/gitit/") {
rewrite ^/(.*) $scheme://$host:$server_port/gitit/$1 redirect;
}
# for gitit: redirect to subfolder before failing
try_files $uri $uri/ @rewrite;
}
location /gitit/ {
proxy_set_header HOST $http_host/gitit;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Referer $http_referer;
add_header Pragma "no-cache";
add_header Cache-Control "no-cache";
proxy_pass http://localhost:5001/;
sub_filter 'action="/' 'action="/gitit/';
sub_filter 'href="/' 'href="/gitit/';
sub_filter 'src="/' 'src="/gitit/';
sub_filter_once off;
sub_filter_types *;
sub_filter_last_modified on;
proxy_redirect off;
}
This is still a problem and nginx rewriting gitit HTML shouldn't be a solution to anything, really. absolute-urls
already fixes all internal wiki links, but static files, all links in the sidebar and menus are wrong.
Let's say I proxy my wiki using nginx to
/wiki/
. The serving of static files and such will break with this. Currently, the documentation appears to insist one should use Apache2 with some HTML rewriting module instead, or simply set up a subdomain for the wiki. This seems suboptimal.A configuration option called
base-url
already exists. If gitit were to use the base-url as a base for static files and links, no fragile/expensive HTML rewriting would be needed, as gitit itself could just return the canonical URL we'd like to have it served at.