Nginx path_info without index.cfm

Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected.
My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works to
load as http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now
looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config,
mod_rewrites, url rewrites, etc. I have tried many, many combinations with
the help of Google, etc. but the above is the closest I have gotten. The
good news is that index.cfm does load as expected, the bad news it that the
path info is not coming through for me. I have seen Paul Klikenberg’s post
on the matter
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo,
and I feel like I’m close, but the wrinkle (I guess) is that in my case the
index.cfm needs to be added into the equation for the pretty urls. Anyway,
here’s my nginx config. Don’t stare at it directly or you may turn to
stone… I find that if you look at it out of your peripheral vision and
glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and 

optional extra
if ($uri ~ “^(.+?.cf[mc])(/.*)”) {
# remember the filepath without path_info
set $script $1;
set $path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}

Brian,

Igal pointed out to me that to get certain cgi vars to resolve properly, in
my case it was the ip address, tomcat also needed some additional
configuration. Check the top of his example here
https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat’s RemoteIpValve to resolve
CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE

A stab in the dark on my part, but perhaps there may be a tomcat valve you
need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamediaOn Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald <@Brian_FitzGerald> wrote:

Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected.
My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works to
load as http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now
looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config,
mod_rewrites, url rewrites, etc. I have tried many, many combinations with
the help of Google, etc. but the above is the closest I have gotten. The
good news is that index.cfm does load as expected, the bad news it that the
path info is not coming through for me. I have seen Paul Klikenberg’s post
on the matter
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo,
and I feel like I’m close, but the wrinkle (I guess) is that in my case the
index.cfm needs to be added into the equation for the pretty urls. Anyway,
here’s my nginx config. Don’t stare at it directly or you may turn to
stone… I find that if you look at it out of your peripheral vision and
glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and

optional extra
if ($uri ~ “^(.+?.cf[mc])(/.*)”) {
# remember the filepath without path_info
set $script $1;
set $path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

I think that the problem is elsewhere here. Are you sure that you want
CGI.PATH_INFO? I personally think (without knowing anything about your
application) that you want CGI.SCRIPT_NAME, which is not the same.

Also, your url-rewriting should probably be done with the rewrite
directive:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/On 2/20/2016 9:43 AM, Nando Breiter wrote:

Brian,

Igal pointed out to me that to get certain cgi vars to resolve
properly, in my case it was the ip address, tomcat also needed some
additional configuration. Check the top of his example here
https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat's RemoteIpValve to resolve
CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE
<Valve className="org.apache.catalina.valves.RemoteIpValve"
protocolHeader="X-Forwarded-Proto"
remoteIpHeader="X-Forwarded-For" protocolHeaderHttpsValue="https" />

A stab in the dark on my part, but perhaps there may be a tomcat valve
you need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald <@Brian_FitzGerald mailto:Brian_FitzGerald> wrote:

Hey guys,

I'm going batty here as I can't get cgi.path_info to show up as
expected. My app uses pretty urls, so I need:
http://dev.myapp.com/how-it-works to load as
http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc
now looks like this:

|
component {
 writeOutput('cgi "path info"<br>');
 writeDump(cgi.path_info);
 abort;
}
|


When running on Apache, this is what I get (good):

<https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png>

When running on Nginx, this is what I get (bad):

<https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png>

Please bare in mind I am awful when it comes to Apache/Nginx
config, mod_rewrites, url rewrites, etc. I have tried many, many
combinations with the help of Google, etc. but the above is the
closest I have gotten. The good news is that index.cfm does load
as expected, the bad news it that the path info is not coming
through for me. I have seen Paul Klikenberg's post on the matter
<http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo>,
and I feel like I'm close, but the wrinkle (I guess) is that in my
case the index.cfm needs to be added into the equation for the
pretty urls. Anyway, here's my nginx config. Don't stare at it
directly or you may turn to stone... I find that if you look at it
out of your peripheral vision and glance away quickly, your
chances are great improved.

|
server {


    listen 80default_server;
    server_name  _;
    index  index.cfm index.html index.htm;
    root /var/www;
    server_name_in_redirect off;


set$path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
#rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
#try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
#try_files $uri /index.cfm$args;
#set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
#set $path_info $2;
#}


#try_files $uri /index.cfm$args;




    try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and
optional extra
if($uri ~"^(.+?\.cf[mc])(/.*)"){
# remember the filepath without path_info
set$script $1;
set$path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
    proxy_set_header XAJP-PATH-INFO $path_info;






    location ~*\.(cfm|cfc|cfr)$ {
        proxy_pass http://127.0.0.1:8888 <http://127.0.0.1:8888>;
        proxy_redirect off;
        proxy_set_header Host$host;
        proxy_set_header X-Forwarded-Host$host;
        proxy_set_header X-Forwarded-Server$host;
        proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        send_timeout 600;
}


}
|




-- 
Love Lucee? Become a supporter and be part of the Lucee project
today! - http://lucee.org/supporters/become-a-supporter.html
---
You received this message because you are subscribed to the Google
Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to lucee+unsubscribe@googlegroups.com
<mailto:lucee+unsubscribe@googlegroups.com>.
To post to this group, send email to lucee@googlegroups.com
<mailto:lucee@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
<https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today!


You received this message because you are subscribed to the Google
Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to lucee+unsubscribe@googlegroups.com
mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com
mailto:lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-o96qO9UChc7t1PXR_G3RHwY9fAK_9XhEKQa-Ez7sDLA%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-o96qO9UChc7t1PXR_G3RHwY9fAK_9XhEKQa-Ez7sDLA%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout.

Cancel this. After rebuilding the docker container, this last issue stopped
happening. Everything is now working as expected (as far as I can tell).

I am really pleased to be migrating this application to Lucee (on Docker)
and running it in Amazon AWS (EC2 Container Engine), or Google Container
Engine, or Digital Ocean. You guys are really great and I’m amped for the
great future I know Lucee holds.

Thank you Geoff Bowers, Igal, Nando, Paul Klinkenberg, Sean and Jon for
your patient help.

BrianOn Sunday, February 21, 2016 at 12:42:47 AM UTC-5, Brian FitzGerald wrote:

Thank you so much for the responses guys. As a result of your help, I am
much closer now. With this configuration (considerably easier on the eyes)
my app is ALMOST running perfectly:

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;

set $path_info $request_uri;

try_files $uri /index.cfm$args;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $path_info;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}

To answer your question, Igal, cgi.path_info is indeed the variable I was
interested in simply because that is the variable Sean uses
https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L23
“under the hood” in fw/1 during the processing of “pretty routes.” The two
main problems my old config had were:

  1. the proxy_set_header statement for XAJP-PATH-INFO had to go inside
    the location block (I had it outside before), and
  2. I needed to discover and use the $request_uri nginx variable, as it
    is the only one I could find that would actually provide the desired value
    for the path_info

So now, requesting http://dev.mysite.com or
http://dev.mysite.com/some-cool-url both correctly route their requests
through the index.cfm file. This is great! I can navigate through most of
the entire app without difficulty.

However, my “final” problem is that when I explicitly make a request to
index.cfm, rather than returning the expected html, it pops up a prompt to
download/save the file index.cfm file (as if nginx didn’t know it should be
handed off to lucee at all). Weird, huh? I think this same misconfiguration
is what is many some of my ajax requests as well.

By looking at that (shorter) nginx config, anything nasty jump out that
would cause the server to prompt a direct download of index.cfm when it is
explicitly requested?

I really appreciate your help guys; I’ll stop bugging you soon.

Brian

On Saturday, February 20, 2016 at 1:54:45 PM UTC-5, Igal wrote:

@Jon – judging by the snippet that Brian posted I’d say that the link you
provided is where he got his code from in the first place.

@Brian – if that is to work then I would expect the header to be
X-AJP-PATH-INFO instead of XAJP-PATH-INFO – perhaps @Paul can chine in and
tell us whether that was a typo there or not.

I still think that you want CGI.SCRIPT_NAME and not CGI.PATH_INFO though.

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 10:08 AM, Jon Clausen wrote:

Brian,

See this post for how to correct the PATH_INFO issue with NGINX/Lucee:

http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo

On February 20, 2016 at 12:59:31 PM, Igal @ Lucee.org (ig...@lucee.org) wrote:

I think that the problem is elsewhere here. Are you sure that you want
CGI.PATH_INFO? I personally think (without knowing anything about your
application) that you want CGI.SCRIPT_NAME, which is not the same.

Also, your url-rewriting should probably be done with the rewrite
directive:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 9:43 AM, Nando Breiter wrote:

Brian,

Igal pointed out to me that to get certain cgi vars to resolve properly,
in my case it was the ip address, tomcat also needed some additional
configuration. Check the top of his example here
https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat’s RemoteIpValve to resolve
CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE

A stab in the dark on my part, but perhaps there may be a tomcat valve you
need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald bmfitz...@gmail.com wrote:

Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected.
My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works to
load as http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now
looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config,
mod_rewrites, url rewrites, etc. I have tried many, many combinations with
the help of Google, etc. but the above is the closest I have gotten. The
good news is that index.cfm does load as expected, the bad news it that the
path info is not coming through for me. I have seen Paul Klikenberg’s post
on the matter
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo,
and I feel like I’m close, but the wrinkle (I guess) is that in my case the
index.cfm needs to be added into the equation for the pretty urls. Anyway,
here’s my nginx config. Don’t stare at it directly or you may turn to
stone… I find that if you look at it out of your peripheral vision and
glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and 

optional extra
if ($uri ~ “^(.+?.cf[mc])(/.*)”) {
# remember the filepath without path_info
set $script $1;
set $path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout
https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today! -

Thank you so much for the responses guys. As a result of your help, I am
much closer now. With this configuration (considerably easier on the eyes)
my app is ALMOST running perfectly:

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;

set $path_info $request_uri;

try_files $uri /index.cfm$args;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $path_info;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}

To answer your question, Igal, cgi.path_info is indeed the variable I was
interested in simply because that is the variable Sean uses
https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L23
“under the hood” in fw/1 during the processing of “pretty routes.” The two
main problems my old config had were:

  1. the proxy_set_header statement for XAJP-PATH-INFO had to go inside
    the location block (I had it outside before), and
  2. I needed to discover and use the $request_uri nginx variable, as it
    is the only one I could find that would actually provide the desired value
    for the path_info

So now, requesting http://dev.mysite.com or
http://dev.mysite.com/some-cool-url both correctly route their requests
through the index.cfm file. This is great! I can navigate through most of
the entire app without difficulty.

However, my “final” problem is that when I explicitly make a request to
index.cfm, rather than returning the expected html, it pops up a prompt to
download/save the file index.cfm file (as if nginx didn’t know it should be
handed off to lucee at all). Weird, huh? I think this same misconfiguration
is what is many some of my ajax requests as well.

By looking at that (shorter) nginx config, anything nasty jump out that
would cause the server to prompt a direct download of index.cfm when it is
explicitly requested?

I really appreciate your help guys; I’ll stop bugging you soon.

BrianOn Saturday, February 20, 2016 at 1:54:45 PM UTC-5, Igal wrote:

@Jon – judging by the snippet that Brian posted I’d say that the link you
provided is where he got his code from in the first place.

@Brian – if that is to work then I would expect the header to be
X-AJP-PATH-INFO instead of XAJP-PATH-INFO – perhaps @Paul can chine in and
tell us whether that was a typo there or not.

I still think that you want CGI.SCRIPT_NAME and not CGI.PATH_INFO though.

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 10:08 AM, Jon Clausen wrote:

Brian,

See this post for how to correct the PATH_INFO issue with NGINX/Lucee:

http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo

On February 20, 2016 at 12:59:31 PM, Igal @ Lucee.org (ig...@lucee.org <javascript:>) wrote:

I think that the problem is elsewhere here. Are you sure that you want
CGI.PATH_INFO? I personally think (without knowing anything about your
application) that you want CGI.SCRIPT_NAME, which is not the same.

Also, your url-rewriting should probably be done with the rewrite
directive:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 9:43 AM, Nando Breiter wrote:

Brian,

Igal pointed out to me that to get certain cgi vars to resolve properly,
in my case it was the ip address, tomcat also needed some additional
configuration. Check the top of his example here
https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat’s RemoteIpValve to resolve
CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE

A stab in the dark on my part, but perhaps there may be a tomcat valve you
need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald < <javascript:> bmfitz...@gmail.com <javascript:>> wrote:

Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected.
My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works to
load as http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now
looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config,
mod_rewrites, url rewrites, etc. I have tried many, many combinations with
the help of Google, etc. but the above is the closest I have gotten. The
good news is that index.cfm does load as expected, the bad news it that the
path info is not coming through for me. I have seen Paul Klikenberg’s post
on the matter
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo,
and I feel like I’m close, but the wrinkle (I guess) is that in my case the
index.cfm needs to be added into the equation for the pretty urls. Anyway,
here’s my nginx config. Don’t stare at it directly or you may turn to
stone… I find that if you look at it out of your peripheral vision and
glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and 

optional extra
if ($uri ~ “^(.+?.cf[mc])(/.*)”) {
# remember the filepath without path_info
set $script $1;
set $path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+un...@googlegroups.com <javascript:>.
To post to this group, send email to <javascript:>lu...@googlegroups.com
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout
https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+un...@googlegroups.com <javascript:>.
To post to this group, send email to <javascript:>lu...@googlegroups.com
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-o96qO9UChc7t1PXR_G3RHwY9fAK_9XhEKQa-Ez7sDLA%40mail.gmail.com?utm_medium=email&utm_source=footer
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-o96qO9UChc7t1PXR_G3RHwY9fAK_9XhEKQa-Ez7sDLA%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAGHrs%3D-o96qO9UChc7t1PXR_G3RHwY9fAK_9XhEKQa-Ez7sDLA%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+un...@googlegroups.com <javascript:>.
To post to this group, send email to <javascript:>lu...@googlegroups.com
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/56C8A94B.1070502%40lucee.org?utm_medium=email&utm_source=footer
https://groups.google.com/d/msgid/lucee/56C8A94B.1070502%40lucee.org.
For more options, visit https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today! -

Hey, glad I could be of assistence, while not even being here :wink:
Next time, feel free to contact me via email or a blog comment if you have issues like this. But I see you already rcvd great help from the Lucee list!

Kind regards,

Paul KlinkenbergOp 22 feb. 2016, om 01:34 heeft Brian FitzGerald <@Brian_FitzGerald> het volgende geschreven:

In other news, I did discover these unicorns on the lucee.nl http://lucee.nl/ site. All in a weekends work, gentlemen.

https://lh3.googleusercontent.com/-kJCaXoqMcHg/VspXW2kAFjI/AAAAAAABsXo/TZ6jnmg7NQ8/s1600/UNICORNS.png

On Sunday, February 21, 2016 at 1:38:44 PM UTC-5, Brian FitzGerald wrote:
Cancel this. After rebuilding the docker container, this last issue stopped happening. Everything is now working as expected (as far as I can tell).

I am really pleased to be migrating this application to Lucee (on Docker) and running it in Amazon AWS (EC2 Container Engine), or Google Container Engine, or Digital Ocean. You guys are really great and I’m amped for the great future I know Lucee holds.

Thank you Geoff Bowers, Igal, Nando, Paul Klinkenberg, Sean and Jon for your patient help.

Brian

On Sunday, February 21, 2016 at 12:42:47 AM UTC-5, Brian FitzGerald wrote:
Thank you so much for the responses guys. As a result of your help, I am much closer now. With this configuration (considerably easier on the eyes) my app is ALMOST running perfectly:

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;

set $path_info $request_uri;

try_files $uri /index.cfm$args;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888 <http://127.0.0.1:8888/>;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $path_info;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}

To answer your question, Igal, cgi.path_info is indeed the variable I was interested in simply because that is the variable Sean uses https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L23 “under the hood” in fw/1 during the processing of “pretty routes.” The two main problems my old config had were:
the proxy_set_header statement for XAJP-PATH-INFO had to go inside the location block (I had it outside before), and
I needed to discover and use the $request_uri nginx variable, as it is the only one I could find that would actually provide the desired value for the path_info
So now, requesting http://dev.mysite.com http://dev.mysite.com/ or http://dev.mysite.com/some-cool-url http://dev.mysite.com/some-cool-url both correctly route their requests through the index.cfm file. This is great! I can navigate through most of the entire app without difficulty.

However, my “final” problem is that when I explicitly make a request to index.cfm, rather than returning the expected html, it pops up a prompt to download/save the file index.cfm file (as if nginx didn’t know it should be handed off to lucee at all). Weird, huh? I think this same misconfiguration is what is many some of my ajax requests as well.

By looking at that (shorter) nginx config, anything nasty jump out that would cause the server to prompt a direct download of index.cfm when it is explicitly requested?

I really appreciate your help guys; I’ll stop bugging you soon.

Brian

On Saturday, February 20, 2016 at 1:54:45 PM UTC-5, Igal wrote:
@Jon – judging by the snippet that Brian posted I’d say that the link you provided is where he got his code from in the first place.

@Brian – if that is to work then I would expect the header to be X-AJP-PATH-INFO instead of XAJP-PATH-INFO – perhaps @Paul can chine in and tell us whether that was a typo there or not.

I still think that you want CGI.SCRIPT_NAME and not CGI.PATH_INFO though.

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 10:08 AM, Jon Clausen wrote:
Brian,

See this post for how to correct the PATH_INFO issue with NGINX/Lucee:

http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railohttp://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo

On February 20, 2016 at 12:59:31 PM, Igal @ Lucee.org (ig...@lucee.org <>) wrote:

I think that the problem is elsewhere here. Are you sure that you want CGI.PATH_INFO? I personally think (without knowing anything about your application) that you want CGI.SCRIPT_NAME, which is not the same.

Also, your url-rewriting should probably be done with the rewrite directive:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 9:43 AM, Nando Breiter wrote:
Brian,

Igal pointed out to me that to get certain cgi vars to resolve properly, in my case it was the ip address, tomcat also needed some additional configuration. Check the top of his example here https://gist.github.com/igal-getrailo/6981111 https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat’s RemoteIpValve to resolve CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE

A stab in the dark on my part, but perhaps there may be a tomcat valve you need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald < <>bmfitz...@gmail.com <>> wrote:
Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected. My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works http://dev.myapp.com/how-it-works to load as http://dev.myapp.com/index.cfm/how-it-works http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config, mod_rewrites, url rewrites, etc. I have tried many, many combinations with the help of Google, etc. but the above is the closest I have gotten. The good news is that index.cfm does load as expected, the bad news it that the path info is not coming through for me. I have seen Paul Klikenberg’s post on the matter http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo, and I feel like I’m close, but the wrinkle (I guess) is that in my case the index.cfm needs to be added into the equation for the pretty urls. Anyway, here’s my nginx config. Don’t stare at it directly or you may turn to stone… I find that if you look at it out of your peripheral vision and glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works <http://192.168.99.100/how-it-works>




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and optional extra
if ($uri ~ "^(.+?\.cf[mc])(/.*)") {
    # remember the filepath without path_info
    set $script $1;
    set $path_info $2;
    # rewrite the url to match the filepath wthout path_info
    # rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;






location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888 <http://127.0.0.1:8888/>;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}


Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com <>.
To post to this group, send email to <>lu...@googlegroups.com <>.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.comhttps://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com.
For more options, visit


Love Lucee? Become a supporter and be part of the Lucee project today! - http://lucee.org/supporters/become-a-supporter.html http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/2501d481-4afa-4fb7-9695-d1b7178985c1%40googlegroups.com https://groups.google.com/d/msgid/lucee/2501d481-4afa-4fb7-9695-d1b7178985c1%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

In other news, I did discover these unicorns on the lucee.nl site. All in a
weekends work, gentlemen.

https://lh3.googleusercontent.com/-kJCaXoqMcHg/VspXW2kAFjI/AAAAAAABsXo/TZ6jnmg7NQ8/s1600/UNICORNS.pngOn Sunday, February 21, 2016 at 1:38:44 PM UTC-5, Brian FitzGerald wrote:

Cancel this. After rebuilding the docker container, this last issue
stopped happening. Everything is now working as expected (as far as I can
tell).

I am really pleased to be migrating this application to Lucee (on Docker)
and running it in Amazon AWS (EC2 Container Engine), or Google Container
Engine, or Digital Ocean. You guys are really great and I’m amped for the
great future I know Lucee holds.

Thank you Geoff Bowers, Igal, Nando, Paul Klinkenberg, Sean and Jon for
your patient help.

Brian

On Sunday, February 21, 2016 at 12:42:47 AM UTC-5, Brian FitzGerald wrote:

Thank you so much for the responses guys. As a result of your help, I am
much closer now. With this configuration (considerably easier on the eyes)
my app is ALMOST running perfectly:

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;

set $path_info $request_uri;

try_files $uri /index.cfm$args;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $path_info;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}

To answer your question, Igal, cgi.path_info is indeed the variable I was
interested in simply because that is the variable Sean uses
https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L23
“under the hood” in fw/1 during the processing of “pretty routes.” The two
main problems my old config had were:

  1. the proxy_set_header statement for XAJP-PATH-INFO had to go inside
    the location block (I had it outside before), and
  2. I needed to discover and use the $request_uri nginx variable, as it
    is the only one I could find that would actually provide the desired value
    for the path_info

So now, requesting http://dev.mysite.com or
http://dev.mysite.com/some-cool-url both correctly route their requests
through the index.cfm file. This is great! I can navigate through most of
the entire app without difficulty.

However, my “final” problem is that when I explicitly make a request to
index.cfm, rather than returning the expected html, it pops up a prompt to
download/save the file index.cfm file (as if nginx didn’t know it should be
handed off to lucee at all). Weird, huh? I think this same misconfiguration
is what is many some of my ajax requests as well.

By looking at that (shorter) nginx config, anything nasty jump out that
would cause the server to prompt a direct download of index.cfm when it is
explicitly requested?

I really appreciate your help guys; I’ll stop bugging you soon.

Brian

On Saturday, February 20, 2016 at 1:54:45 PM UTC-5, Igal wrote:

@Jon – judging by the snippet that Brian posted I’d say that the link you
provided is where he got his code from in the first place.

@Brian – if that is to work then I would expect the header to be
X-AJP-PATH-INFO instead of XAJP-PATH-INFO – perhaps @Paul can chine in and
tell us whether that was a typo there or not.

I still think that you want CGI.SCRIPT_NAME and not CGI.PATH_INFO though.

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 10:08 AM, Jon Clausen wrote:

Brian,

See this post for how to correct the PATH_INFO issue with NGINX/Lucee:

http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo

On February 20, 2016 at 12:59:31 PM, Igal @ Lucee.org (ig...@lucee.org) wrote:

I think that the problem is elsewhere here. Are you sure that you want
CGI.PATH_INFO? I personally think (without knowing anything about your
application) that you want CGI.SCRIPT_NAME, which is not the same.

Also, your url-rewriting should probably be done with the rewrite
directive:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

Igal Sapir
Lucee Core Developer
Lucee.org http://lucee.org/
On 2/20/2016 9:43 AM, Nando Breiter wrote:

Brian,

Igal pointed out to me that to get certain cgi vars to resolve properly,
in my case it was the ip address, tomcat also needed some additional
configuration. Check the top of his example here
https://gist.github.com/igal-getrailo/6981111 where it says:

if connecting to Tomcat, use Tomcat’s RemoteIpValve to resolve
CGI.REMOTE_ADDR, CGI.SERVER_NAME, and CGI.SERVER_PORT_SECURE

A stab in the dark on my part, but perhaps there may be a tomcat valve you
need to set for cgi.path_info.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

On Sat, Feb 20, 2016 at 2:31 PM, Brian FitzGerald bmfitz...@gmail.com wrote:

Hey guys,

I’m going batty here as I can’t get cgi.path_info to show up as expected.
My app uses pretty urls, so I need: http://dev.myapp.com/how-it-works to
load as http://dev.myapp.com/index.cfm/how-it-works.

I have stripped my application down to nothing. My Application.cfc now
looks like this:

component {
writeOutput(‘cgi “path info”
’);
writeDump(cgi.path_info);
abort;
}

When running on Apache, this is what I get (good):

https://lh3.googleusercontent.com/-D55F2nlgj-Y/VshobhMHazI/AAAAAAABsF8/zrYm4E8SeWM/s1600/path_info_apache.png

When running on Nginx, this is what I get (bad):

https://lh3.googleusercontent.com/-QsL7ll3Gahw/VshoiHLKXQI/AAAAAAABsGA/T77nyFVqeA4/s1600/path_info_nginx.png

Please bare in mind I am awful when it comes to Apache/Nginx config,
mod_rewrites, url rewrites, etc. I have tried many, many combinations with
the help of Google, etc. but the above is the closest I have gotten. The
good news is that index.cfm does load as expected, the bad news it that the
path info is not coming through for me. I have seen Paul Klikenberg’s post
on the matter
http://www.lucee.nl/post.cfm/enable-path-info-on-nginx-with-lucee-and-railo,
and I feel like I’m close, but the wrinkle (I guess) is that in my case the
index.cfm needs to be added into the equation for the pretty urls. Anyway,
here’s my nginx config. Don’t stare at it directly or you may turn to
stone… I find that if you look at it out of your peripheral vision and
glance away quickly, your chances are great improved.

server {

listen 80 default_server;
server_name  _;
index  index.cfm index.html index.htm;
root   /var/www;
server_name_in_redirect off;


set $path_info "";


#test url: http://192.168.99.100/how-it-works




#attempt1 -> server 404 not found
#if (!-e $request_filename){
    #rewrite ^(.*)$ /index.cfm/$1 break;
#}


#attempt2 -> loads index.cfm file, CGI path_info is blank
#location / {
    #try_files $uri /index.cfm$1;
#}


#attempt3 (server 500 error)
#try_files $uri /index.cfm/$args;


#attempt4
#if (!-e $request_filename){
   #try_files $uri /index.cfm$args;
   #set $path_info $args;
#}


#attempt5 > 404 not found
#rewrite ^(.*)$ /index.cfm$1;
#set $path_info $1;


#attempt6 > 404 not found
#rewrite ^(.*)$ /index.cfm$1 break;
#set $path_info $1;


#attempt7 > loading index.cfm file but not passing $path_info
#if ($uri ~ "^(.+.cfm)(/.+)") {
    #set $path_info $2;
#}


#try_files $uri /index.cfm$args;




try_files $uri /index.cfm$args;


# if the extension .cfm or .cfc is found, followed by a slash and 

optional extra
if ($uri ~ “^(.+?.cf[mc])(/.*)”) {
# remember the filepath without path_info
set $script $1;
set $path_info $2;
# rewrite the url to match the filepath wthout path_info
# rewrite ^.+$ $script break;
}
# set the custom path_info header
proxy_set_header XAJP-PATH-INFO $path_info;

location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
}

}


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
https://groups.google.com/d/msgid/lucee/891fc7df-8c27-496c-8a20-77a9239e5706%40googlegroups.com
.
For more options, visit

I am really pleased to be migrating this application to Lucee (on Docker)
and running it in Amazon AWS (EC2 Container Engine), or Google Container
Engine, or Digital Ocean. You guys are really great and I’m amped for the
great future I know Lucee holds.

We’ve been having considerable success with DockerCloud
(https://cloud.docker.com/) using AWS as a provider. DockerCloud also
supports DigitalOcean and others.

I found it too hard to orchestrate a lot of little apps through to ECS via
Beanstalk and haven’t looked back since we hooked up DockerCloud (nee Tutum
Cloud).

GB

This solution doesn’t seem to work with url’s that have encoding in them, nginx seems to think it needs to decode it before passing into the proxy… messing up in the process.

so nginx passes “some20great20product” to Lucee
http://docker:8543/index.cfm/brand/some%20great%20product/

Anybody know how to tell nginx not to tamper with the ugly string?

You mean it simply strips down the % symbols? That doesn’t sound right. Can you post the relevant nginx config?

behavior seems similar to these,

https://trac.nginx.org/nginx/ticket/727
https://serverfault.com/questions/459369/disabling-url-decoding-in-nginx-proxy

I’ve tried two flavors, both work until an encoded url is passed

server {
  listen 443 default ssl;
  ssl_certificate /etc/nginx/server.crt;
  ssl_certificate_key /etc/nginx/server.key;

  server_name _;
  index  index.cfm index.html index.htm;
  root   /var/www/aslx/wwwfiles;
  server_name_in_redirect off;

  set $path_info $request_uri;

  try_files $uri /index.cfm$args;

  location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $pathinfo;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
  }
}

server {
  listen 80 default_server;
  server_name _;
  index  index.cfm index.html index.htm;
  root   /var/www/aslx/wwwfiles;
  server_name_in_redirect off;

  set $pathinfo "";
  # if the extension .cfm or .cfc is found, followed by a slash and optional extra
  if ($uri ~ "^(.+?\.cf[mc])(/.*)") {
    # remember the filepath without path_info
    set $script $1;
    set $pathinfo $2;
    # rewrite the url to match the filepath wthout path_info
    rewrite ^.+$ $script break;
  }

  location ~* \.(cfm|cfc|cfr)$ {
    proxy_pass http://127.0.0.1:8888;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header XAJP-PATH-INFO $pathinfo;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
  }
}