Last active
June 10, 2016 19:29
-
-
Save borutmrak/bc732df9278c2061ea10 to your computer and use it in GitHub Desktop.
Nginx - Request Tracker in a subdirectory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I had Request Tracker running on https://support.example.com. | |
Now I want to move it to https://example.com/support/. | |
In Request Tracker itself, the configuration file contained this: | |
Set( $WebDomain, 'support.example.com' ); | |
Set( $WebPath, ""); | |
Set( $WebPort, '443' ); | |
What I want to achieve is this: | |
Set( $WebDomain, 'example.com' ); | |
Set( $WebPath, "/support"); | |
Set( $WebPort, '443' ); | |
This part is OK. | |
My original nginx configuration was (just the relevant parts, leaving out SSL stuff etc) | |
server { | |
listen [::]:443 ssl spdy; | |
listen 0.0.0.0:443 ssl spdy; | |
server_name support.example.com; | |
location /REST/1.0/NoAuth { | |
# mail submission - only allow from this machine | |
allow 127.0.0.1; | |
allow ::1; | |
deny all; | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_NAME ""; | |
fastcgi_param PATH_INFO $uri; | |
fastcgi_pass unix:/srv/web/example.com/rt/var/run/fcgi-socket; | |
} | |
location / { | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_NAME ""; | |
fastcgi_param PATH_INFO $uri; | |
fastcgi_pass unix:/srv/web/example.com/rt/var/run/fcgi-socket; | |
} | |
location /NoAuth/images { | |
root /srv/web/example.com/rt/share/html; | |
} | |
} | |
The Request Tracker docs on nginx are here: | |
https://www.bestpractical.com/docs/rt/4.0/web_deployment.html#nginx | |
There is also a RT module that can control nginx, the configuration it | |
creates is more advanced and available here: | |
https://github.com/bestpractical/rt-extension-nginx/tree/master/etc | |
The configuration template contains things like: | |
location <% RT->Config->Get('WebPath') %>/NoAuth/images/ { | |
root <% $RT::BasePath %>; | |
try_files | |
local/html$uri | |
<% join ' ', map "$_\$uri", map File::Spec->abs2rel($_, $RT::BasePath), RT->PluginDirs('html') %> | |
share/html$uri | |
@main | |
; | |
expires 1M; | |
} | |
But unfortunately, https://github.com/bestpractical/rt-extension-nginx/blob/master/sbin/rt-generate-nginx-conf: | |
if ( RT->Config->Get('WebPath') ) { | |
die sprintf | |
"Only empty WebPath is supported at the moment," | |
." eg serving RT from http://rt.%s/," | |
." not http://%s%s/", | |
RT->Config->Get('WebDomain'), | |
RT->Config->Get('WebDomain'), | |
RT->Config->Get('WebPath'), | |
; | |
} | |
So it seems I can't use it as-is. | |
My current config at https://example.com/support (not working): | |
location /support { | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_NAME ""; | |
fastcgi_param PATH_INFO $uri; | |
fastcgi_pass unix:/srv/web/example.com/rt/var/run/fcgi-socket; | |
} | |
location /support/NoAuth/images { | |
alias /srv/web/example.com/rt/share/html/NoAuth/images; | |
} | |
(I replaced root with alias in NoAuth/images to get rid of the /support prefix, that part seems to work). | |
But the /support redirects me to /support/NoAuth/Login.html?next=xxxxxxxxxxxx which creates a redirect loop. Error log: | |
Request: /support/NoAuth/Login.html?next=0ecb403faeafb6235bff1d5c13e051f4 | |
Reason: your browser did not supply a Referrer header (/srv/web/example.com/rt/sbin/../lib/RT/Interface/Web.pm:397)" while reading upstream, client: x.x.x.x, server: _, request: "GET /support/NoAuth/Login.html?next=0ecb403faeafb6235bff1d5c13e051f4 HTTP/1.1", upstream: "fastcgi://unix:/srv/web/example.com/rt/var/run/fcgi-socket:", host: "example.com" | |
2014/05/22 22:49:45 [error] 1502#0: *1630 FastCGI sent in stderr: "[24920] [Thu May 22 20:49:45 2014] [notice]: Marking original destination as having side-effects before redirecting for login. | |
Request: /support/NoAuth/Login.html?next=a5cdc70b9d67a291f3de8aac38f3a7e5 | |
Reason: your browser did not supply a Referrer header (/srv/web/example.com/rt/sbin/../lib/RT/Interface/Web.pm:397)" while reading upstream, client: x.x.x.x, server: _, request: "GET /support/NoAuth/Login.html?next=a5cdc70b9d67a291f3de8aac38f3a7e5 HTTP/1.1", upstream: "fastcgi://unix:/srv/web/example.com/rt/var/run/fcgi-socket:", host: "example.com" | |
2014/05/22 22:49:45 [error] 1502#0: *1630 FastCGI sent in stderr: "[24920] [Thu May 22 20:49:45 2014] [notice]: Marking original destination as having side-effects before redirecting for login. | |
Request: /support/NoAuth/Login.html?next=c21c66b7781027ce4d10f2a771a7df63 | |
Reason: your browser did not supply a Referrer header (/srv/web/example.com/rt/sbin/../lib/RT/Interface/Web.pm:397)" while reading upstream, client: x.x.x.x, server: _, request: "GET /support/NoAuth/Login.html?next=c21c66b7781027ce4d10f2a771a7df63 HTTP/1.1", upstream: "fastcgi://unix:/srv/web/example.com/rt/var/run/fcgi-socket:", host: "example.com" | |
Found out: You need to set SCRIPT_NAME to "/rt"
fastcgi_param SCRIPT_NAME "/rt";
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you found a way to solve this? Same problem here.