Rt3.8.17 / nginx and document-root

Hi,

because nginx ist about 20-30% faster than apache2, we tries to move to nginx. Our URL is http:///rt
so WebPath insode RT_SiteConfig.pm is set to “/rt”.

Our current nginx config (1) works fine (but only in the document root http://, but not with http:///rt)

I’m not familiar with nginx and spent now about 4 hours trying to configure rt3+nginx to use http:///rt as the base-url - but I was not able to manage it.

Maybe somebody show me how to configure RT/ngnix for a non-root URL ?

regards
Danny

(1) /etc/nginx/conf.d/rt3.conf

server {
listen 80;
server_name artee2.domain.de;

root /opt/rt3/share/html;
index index.html index.htm;

location / {
fastcgi_pass unix:/opt/rt3/var/fastcgi.sock;

include        /etc/nginx/fastcgi_params;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param   SCRIPT_NAME "";
fastcgi_param   PATH_INFO $uri;

}
}

Viele Gruesse
Daniel Schwager

DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de

smime.p7s (2.23 KB)

Search github for rt-extension-nginx as good starting point.> Am 24.12.2014 um 14:21 schrieb Daniel Schwager Daniel.Schwager@dtnet.de:

Hi,

because nginx ist about 20-30% faster than apache2, we tries to move to nginx. Our URL is http:///rt
so WebPath insode RT_SiteConfig.pm is set to “/rt”.

Our current nginx config (1) works fine (but only in the document root http://, but not with http:///rt)

I’m not familiar with nginx and spent now about 4 hours trying to configure rt3+nginx to use http:///rt as the base-url - but I was not able to manage it.

Maybe somebody show me how to configure RT/ngnix for a non-root URL ?

regards
Danny

(1) /etc/nginx/conf.d/rt3.conf

server {
listen 80;
server_name artee2.domain.de;

root /opt/rt3/share/html;
index index.html index.htm;

location / {
fastcgi_pass unix:/opt/rt3/var/fastcgi.sock;

include /etc/nginx/fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME “”;
fastcgi_param PATH_INFO $uri;
}
}

Viele Gruesse
Daniel Schwager


DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de

Hi Torsten,

thanks for this information - there’s the fix - important
lines are “location” and “rewrite” - see (1).

Works now like a charme (-:

Thx
Danny

(1) nginx / non-root configuration (http://artee2.domain.de/rt)

server {
listen 80;
server_name artee2.domain.de;
root /tmp;

        location ^~ /rt/ {
            fastcgi_pass   unix:/opt/rt3/var/fastcgi.sock;

            rewrite ^/rt(/.*)$ $1 break;

            include         /etc/nginx/fastcgi_params;
            fastcgi_param  QUERY_STRING       $query_string;
            fastcgi_param  REQUEST_METHOD     $request_method;
            fastcgi_param  CONTENT_TYPE       $content_type;
            fastcgi_param  CONTENT_LENGTH     $content_length;

            fastcgi_param   SCRIPT_NAME "";
            fastcgi_param   PATH_INFO $uri;
        }

}

smime.p7s (2.23 KB)

Hi all,

thanks for this information - there’s the fix - important
lines are “location” and “rewrite” - see (1).

I updated to rt 4.2.6 - now, the combination of rt / nginx / fastcgi / document-root ‘/rt’ does not work again.

My goal is to map a RT with nginx to a URL like “http://www.domain.de:8080/rt” (instead of “http://www.domain.de:8080”)

Tonight, I played around and found the following working setup:

/etc/nginx/conf.d/rt4.conf

server {

listen       8080;
server_name  host.domain.de;
root /tmp;

# /opt/rt4/etc/RT_SiteConfig.pm                                                                                                                                                                                                          
#   Set($WebDomain, "host.domain.de");                                                                                                                                                                                                   
#   Set($WebPort , 8080);                                                                                                                                                                                                                
#   Set($WebPath , "/rt");                                                                                                                                                                                                               
#   Set(@ReferrerWhitelist, qw(extranet.domain.de:443 host.domain.de:8080 ));                                                                                                                                                            

location  / {

    ### <original /etc/nginx/fastcgi_params - debian 7.x>                                                                                                                                                                                
    # include         /etc/nginx/fastcgi_params;                                                                                                                                                                                         
      fastcgi_param QUERY_STRING            $query_string;
      fastcgi_param REQUEST_METHOD          $request_method;
      fastcgi_param CONTENT_TYPE            $content_type;
      fastcgi_param CONTENT_LENGTH          $content_length;

      fastcgi_param SCRIPT_FILENAME         $request_filename;
      fastcgi_param SCRIPT_NAME             $fastcgi_script_name;
      fastcgi_param REQUEST_URI             $request_uri;
      fastcgi_param DOCUMENT_URI            $document_uri;
      fastcgi_param DOCUMENT_ROOT           $document_root;
      fastcgi_param SERVER_PROTOCOL         $server_protocol;

      fastcgi_param GATEWAY_INTERFACE       CGI/1.1;
      fastcgi_param SERVER_SOFTWARE         nginx/$nginx_version;

      fastcgi_param REMOTE_ADDR             $remote_addr;
      fastcgi_param REMOTE_PORT             $remote_port;
      fastcgi_param SERVER_ADDR             $server_addr;
      fastcgi_param SERVER_PORT             $server_port;
      fastcgi_param SERVER_NAME             $server_name;

      fastcgi_param HTTPS                   $https;

      # PHP only, required if PHP was built with --enable-force-cgi-redirect                                                                                                                                                             
      fastcgi_param REDIRECT_STATUS         200;
    ### </original /etc/nginx/fastcgi_params>                                                                                                                                                                                            

    fastcgi_pass   unix:/opt/rt4/var/fastcgi.sock;

    fastcgi_param   SCRIPT_NAME "/rt";
    fastcgi_param   PATH_INFO $uri;

 }

}

rt-server.fcgi was called like this:
/opt/rt4/sbin/rt-server.fcgi --pidfile=/opt/rt4/var/fastcgi.pid --socket=/opt/rt4/var/fastcgi.sock 2> /dev/null

Maybe, I can help other admins in the future not to spend that much time searching for a working solution.

regards
Danny

smime.p7s (2.23 KB)

Wow, thanks! It’s next in Quere here.> Am 14.01.2015 um 08:43 schrieb Daniel Schwager Daniel.Schwager@dtnet.de:

Hi all,

thanks for this information - there’s the fix - important
lines are “location” and “rewrite” - see (1).

I updated to rt 4.2.6 - now, the combination of rt / nginx / fastcgi / document-root ‘/rt’ does not work again.

My goal is to map a RT with nginx to a URL like “http://www.domain.de:8080/rt” (instead of “http://www.domain.de:8080”)

Tonight, I played around and found the following working setup:

/etc/nginx/conf.d/rt4.conf

server {

listen 8080;
server_name host.domain.de;
root /tmp;

/opt/rt4/etc/RT_SiteConfig.pm

Set($WebDomain, “host.domain.de”);

Set($WebPort , 8080);

Set($WebPath , “/rt”);

Set(@ReferrerWhitelist, qw(extranet.domain.de:443 host.domain.de:8080 ));

location / {

   ### <original /etc/nginx/fastcgi_params - debian 7.x>                                                                                                                                                                                
   # include         /etc/nginx/fastcgi_params;                                                                                                                                                                                         
     fastcgi_param QUERY_STRING            $query_string;
     fastcgi_param REQUEST_METHOD          $request_method;
     fastcgi_param CONTENT_TYPE            $content_type;
     fastcgi_param CONTENT_LENGTH          $content_length;

     fastcgi_param SCRIPT_FILENAME         $request_filename;
     fastcgi_param SCRIPT_NAME             $fastcgi_script_name;
     fastcgi_param REQUEST_URI             $request_uri;
     fastcgi_param DOCUMENT_URI            $document_uri;
     fastcgi_param DOCUMENT_ROOT           $document_root;
     fastcgi_param SERVER_PROTOCOL         $server_protocol;

     fastcgi_param GATEWAY_INTERFACE       CGI/1.1;
     fastcgi_param SERVER_SOFTWARE         nginx/$nginx_version;

     fastcgi_param REMOTE_ADDR             $remote_addr;
     fastcgi_param REMOTE_PORT             $remote_port;
     fastcgi_param SERVER_ADDR             $server_addr;
     fastcgi_param SERVER_PORT             $server_port;
     fastcgi_param SERVER_NAME             $server_name;

     fastcgi_param HTTPS                   $https;

     # PHP only, required if PHP was built with --enable-force-cgi-redirect                                                                                                                                                             
     fastcgi_param REDIRECT_STATUS         200;
   ### </original /etc/nginx/fastcgi_params>                                                                                                                                                                                            

   fastcgi_pass   unix:/opt/rt4/var/fastcgi.sock;

   fastcgi_param   SCRIPT_NAME "/rt";
   fastcgi_param   PATH_INFO $uri;

}

}

rt-server.fcgi was called like this:
/opt/rt4/sbin/rt-server.fcgi --pidfile=/opt/rt4/var/fastcgi.pid --socket=/opt/rt4/var/fastcgi.sock 2> /dev/null

Maybe, I can help other admins in the future not to spend that much time searching for a working solution.

regards
Danny