Mapping issue @Lucee-5.3.7.48

Hi Support,

The following spec is my current stack.

OS: Ubuntu 20.04.2 LTS
Java Version: openjdk 11.0.11 2021-04-20
Tomcat Version: Tomcat 9
Lucee Version: 5.3.7.48

I setup the Lucee server like this combo (Ubuntu + Nginx + Tomcat + Lucee- 5.3.7.48). Our current application was developed by AdobeCF9. Since re-platforming to Lucee, we encountered an issue between CF Admin mappings and the virtual directories. Please see the attached screenshot of mapping where in Lucee admin panel.

For instance, assume the site name is (example.com) and admin portal should be like (example.com/adminportal/index.cfm).

According to above screenshot, the admin panel is working fine with this mapping. but if I am trying to access that website (example.com), it is throwing an error. Please see the nginx conf details:

example.conf
server {
listen 80;
server_name example.com;
root /example/www;

Mod_cfml (Lucee) specific: add a unique ID for this server block.

For more info, see http://www.modcfml.org/index.cfm/install/web-server-components/nginx-all-os/

set $lucee_context “example.com”;
include lucee.conf;
}

How I am trying?
I am put a test.html file under the root dir “/example/www” that is showing as “404 Not Found”
404

And if I trying with a simple test.cfm file that is also getting an error

Both test.html and test.cfm has a simple text like “Hello World”

If I am modify in Lucee mapping like “/” —> /example/www the admin portal shouldn’t work

Can anyone know what is the issue is? if its related to mapping, how possible to override by Nginx conf root directory?

Thanks in Advance!

unless you actually created the directory /example/www in Ubuntu the default web directory is /var/www/html

@Terry_Whitney
I am using NGINX with custom root directory…

Well that information does help.

you will need something like this for nginx

**extensions** 
location ~ \.cfm$ {
  proxy_pass        http://localhost:8888;
  proxy_set_header  X-Real-IP $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header  Host $http_host;
}
location ~ \.cfc$ {
  proxy_pass        http://localhost:8888;
  proxy_set_header  X-Real-IP $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header  Host $http_host;
}
location ^~/flexgateway-or-otherluceeservice/* {
  proxy_pass        http://localhost:8888;
  proxy_set_header  X-Real-IP $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header  Host $http_host;
}

**the server section**
server {
  listen          80;
  server_name     YOUR_DOMAIN;
  root            /PATH/TO/YOUR/WEB/APPLICATION;
  location / {
    index index.cfm;
  }
  location ~ \.cfc$ {
    proxy_pass        http://localhost:8888;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
  }
  location ~ \.cfml$ {
    proxy_pass        http://localhost:8888;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
  }
  location ^~/flexgateway-or-otherluceeservice/* {
    proxy_pass        http://localhost:8888;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
  }
}

in the luceeRoot/tomcat/conf/
you will want to edit (vi / nano) the server.xml

Around line 118 there is
secretRequired=“true”
change that to
secretRequired=“false”

Restart lucee
Restart nginx

@Terry_Whitney
Thanks for the reply.

Now test.html is working fine! when I am trying http://example.com/test.cfm a pop-up box came up and asking to open the test.cfm file with listed application(kind of download that test.cfm file)

Also there is no "secretRequired=“true” parameter inside the server.xml file

How did you install Lucee?

I am asking as you should have /opt/lucee/tomcat/conf/server.xml

I followed the stuff from Pete where located here - GitHub - foundeo/ubuntu-nginx-lucee: Script for standing up a Lucee server using nginx and Tomcat on Ubuntu

In this case tomcat is installed under /etc directory and there is a server.xml file “/etc/tomcat9/server.xml” and couldn’t find them on it.

NO result found
grep -irl “secretRequired” /etc/tomcat9/server.xml
root@example#

Let me go look at that script, typically the ubuntu nginx install I suggest
install nginx (apt-get install nginx-full)
download and install lucee
confirm lucee is running
then edit as above, no script required.

if you are using that script, it installs lucee as a jar file
you would just edit your custom file sites-available/example.com.conf
server {
listen 80;
server_name localhost;
root /web/wwwroot/;

Mod_cfml (Lucee) specific: add a unique ID for this server block.

For more info, see http://www.modcfml.org/index.cfm/install/web-server-components/nginx-all-os/

set $lucee_context “localhost”;

include lucee.conf;
}

yes the same setup/conf files I’m using

one thing to clarify here, nginx doesn’t know anything about lucee mappings and lucee doesn’t know about webserver mappings ( we want to change that in 6 https://luceeserver.atlassian.net/browse/LDEV-694 )

1 Like

so you are accessing “localhost” with a sites-enabled file for “localhost.conf”?

I ask as the sample suggests example.com.conf, and the context in the script points to example.com, which is unique, and ok, the work around would be to just add example.com to your /etc/hosts file and point 127.0.0.1 example.com

@Zackster @Terry_Whitney

Thanks a lot to helping me for this issue!

I tried both of your suggestions and oversee all the conf files. Here I am attaching my conf files and error page

Current issue is: when I am accession http://domain.com/test.cfm is pop up came in.


nginx -t

nginx: [warn] conflicting server name “footytips.com” on 0.0.0.0:80, ignored

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

request: “GET /test.html HTTP/1.1”, upstream: “http://127.0.0.1:8888/test.html”, host: “footytips.com

2021/08/04 07:11:19 [error] 7504#7504: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 10.20.10.10, server: footytips.com, request: “GET /test.html HTTP/1.1”, upstream: “http://127.0.0.1:8888/test.html”, host: “footytips.com

2021/08/04 07:12:14 [warn] 7666#7666: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

2021/08/04 07:12:14 [warn] 7667#7667: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

2021/08/04 07:13:28 [warn] 7675#7675: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

2021/08/04 07:13:28 [warn] 7676#7676: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

2021/08/04 07:15:26 [warn] 7684#7684: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

2021/08/04 07:15:41 [warn] 7685#7685: conflicting server name “footytips.com” on 0.0.0.0:80, ignored

footytips.conf (469 Bytes) server.xml (7.1 KB) nginx.conf (1.5 KB) lucee.conf (668 Bytes) lucee-proxy.conf (1.3 KB) lucee-global.conf (122 Bytes)

seems it related to Nginx conf issue, Please have a check these files and advice HowTo solve this issue

Referred URLs : Using Nginx With ColdFusion or Lucee - Nando @ Aria Media

Thanks in Advance
Abhilash

in server.xml line 69 you are telling tomcat to redirect port 8080 to port 8443
in server.xml line 130 you set the host “footytips.com” to be handled by tomcat

Then your nginx.conf picks up footyfips.conf
so now you are trying to handle footytips.com with nginx

You then have 2 lines that look like they are doing exactly the same thing, depending on what nginx-cf-proxy-settings.conf contains

location / {
proxy_pass http://127.0.0.1:8443/;
include /etc/nginx/nginx-cf-proxy-settings.conf;
}
location ~ .(cfm|cfml|cfc)$ {
# proxy_pass http://127.0.0.1:8888;
include /etc/nginx/nginx-cf-proxy-settings.conf

Then in lucee-proxy.conf you are saying
line 1, push lucee to port 8080
port 8080, per server.xml becomes 8443

You need to choose who is handling footy, nginx or tomcat.

to quickly fix, make footy just a context install and not a vhost for tomcat

My suggestion, and its just that as I know nothing of what you are running or trying to do besides lucee

down tomcat
down nginx
install apache2 , install lucee with the default installer
add footy as your default site
It will just work and you will gain in performance out of the box as nginx isnt the greatest at handling static files, or ColdFusion apps.

Though here is suggestion if you want to make this a production site
apache2 - > proxy config --> lucee
any other dynamic language such as php --> apache2 php-fpm or nginx
any static file -> apache2

@Terry_Whitney

I can’t change the Lucee server stack because that combination which meet our business requirement.

Regarding that port “8080” and “8443” where in conf files was an experiment actually I forgot to remove them. I believe Lucee has a default port which is “8888” that’s what I want to tried with but that port does not listen into the server that’s the reason I tried both port in conf. Please see the snippet of listening port in server.

ss -ltnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:((“nginx”,pid=5632,fd=6),(“nginx”,pid=5631,fd=6),(“nginx”,pid=5630,fd=6))
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* users:((“systemd-resolve”,pid=400,fd=13))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:((“sshd”,pid=677,fd=3))
LISTEN 0 100 :8080 : users:((“java”,pid=4888,fd=39))
LISTEN 0 128 [::]:22 [::]:
users:((“sshd”,pid=677,fd=4))

If I comment out the "proxy_pass " the output result would be “404”
As per @Zackster suggestion I went to changes in server.xml and I found another blog is mentioned the same way to implement a Nginx server block.

Ref - https://luceeserver.atlassian.net/browse/LDEV-694
Using Nginx With ColdFusion or Lucee - Nando @ Aria Media

@pfreitag probably he may face the same kind of issue?

Thanks @Terry_Whitney
Abhilash

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      5630/nginx: master  
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      400/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      677/sshd: /usr/sbin 
tcp6       0      0 :::8080                 :::*                    LISTEN      4888/java           
tcp6       0      0 :::22                   :::*                    LISTEN      677/sshd: /usr/sbin 
udp        0      0 127.0.0.53:53           0.0.0.0:*                           400/systemd-resolve 

Lucee if its installed using the installer is port 8888, if you install it as a jar, its under tomcat and the server.xml assigns the port

your lucee install should be on port 8080 which you have a pointer as a proxy to the wrong port 8443

I would use nginx to assign the vhost and tomcat to assign the application
and you need tomcat listening on ipv4, its not running or its not listening.

give me a few hours, I may have some free time this afternoon to fire up a vm and have a better look.

on further investigation, the issue is happened due to the mapping

I made two mapping by in Lucee administration so our admin panel site is working fine whereas actual website couldn’t resolve by due to the path

Actual path(root_dir) is /footytips/www, if I give ‘/’ is pointing to “/footytips/www” our admin panel does not work whereas a sample cfm file is working fine from /footytips/www which means our actual website is able to work!!

If I do ‘/’ is pointing to “/footytips” our admin panel is working fine whereas our website root dir pointing to /footytips instead of /footytips/www that’s the reason I used this path mapping through server.xml files and nginx nothing is works!

This is 100% related to mapping problem, if you have any specific settings either Nginx or Tomcat please provide me!

Thanks
Abhilash

@Abhilash

I installed ubuntu, 20.04 lts
downloaded the script, modified the installer.sh to install the latest version of lucee.
I ran the installer as root
The only thing that had to be done was add a site to the sites-enabled and as a matter of habbit, I added the site to the host file

this is footytips_com.conf in /etc/nginx/sites-enabled/

server {
  listen 80;
  server_name footytips.com;
  root /footytips/www;

  location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
      # specific settings for files ending in suffixes .ico, .css, .js, gif, etc
  }

  location / {
      #proxy_pass  http://127.0.0.1:8080/;
      include     /etc/nginx/lucee-proxy.conf;
  }
  location ~ \.(cfm|cfml|cfc)$ {
     # proxy_pass  http://127.0.0.1:8080;
      include     /etc/nginx/lucee-proxy.conf;
  }
}

lucee-proxy.conf was created by the installer script and was not modified.

the server.xml in /etc/tomcat9 should not be what was provided by the installer. Remove your vhost entry

@Terry_Whitney

I 100% agreed with you! I have experienced what you suggested and searched same old issue here and walked through then applied those recommendation as well! outcome is negative!

I am thinking I want to give you more clarity with this issue. As per your current suggestion, I could see the output of test.cfm file where the condition that only for one website.

I have two website, the first one root directory is under “/footytips/cfm” which is good with mapping by Lucee server admin, settings is like this
Virtual Resource


/website1 —pointing to----> /footytips/cfm
/ —pointing to----> /footytips/

for website1, we don’t have any NGINX virtual directory, It is working as expected by Lucee server mapping!

The problem is website2

Apparently website2 root directory is under “/footytips/www” where all static and dynamic pages located here and also this website has a NGINX virtual host (footytips.conf) which is I already uploaded in last post. if I mention “/” as pointing to “/footytips/www” where in Lucee server mapping section, the website1 does not work at all whereas website2 can work. This is why I want to work website1 as by Lucee server mapping another one should work by NGINX reverse proxying to tomcat that means website2 static files can parse by NGINX and dynamic should parse by Tomcat as well.

In order to achieve, I applied some of the solution where in adding a virtual host in “server.xml” then make changes in footytips.conf files accordingly. None of them are worked yet!

If you want see the same issue, please go and make the changes like website1 by Lucee admin —> Archives & Resources ----> Mappings set like this:

Virtual Resource


/website1 —pointing to----> /footytips/cfm
/ —pointing to----> /footytips/

Expected setting like / —pointing to----> /footytips/www which is same setting in our Windows + CF9 server does works fine.

Then try to access both sites

Thanks in Advance
Abhilash S V