Search code examples
tomcatnginxrailolucee

Request lands in Tomcat's catch-all instead of the desired host


After setting up a new install of Nginx and Lucee on an OpenSuse VM I've now reached a point where I can access the Lucee admin via the internal IP and Tomcat port, but if I try to access the little test page I've set up, I end up on the catch-all instead, meaning Lucee's welcome page.

It's probably something extremely simple, but I'm constantly overlooking the detail that's probably causing it, so I hope that one of you can point me in the right direction. Here's the condensed version of the server.xml and nginx.conf files after removing all the stuff I've already commended out without seeing a difference.

The domain-based host block and the defined upstream are there to make it easier to add additional sites t some later point.

user  web-user;
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    use epoll;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    server_tokens off;
    server_names_hash_bucket_size 64;

    sendfile        on;
    keepalive_timeout  65;

    gzip    on;
    gzip_http_version   1.1;
    gzip_comp_level 4;
    gzip_types  text/plain text/javascript application/javascript text/css application/x-javascript application/xml application/xml+rss  application/json  application/font-woff;
    gzip_vary   on;

    upstream    lucee_servers {
        ip_hash;
        server  localhost:8888;
        keepalive   32;
    }

    #############
    # sites
    #############
    server {
        server_name .exampleurl.de;
        listen  80;
        root    /opt/wwwRailo/exampleurl;
        index index.cfm;

        expires 1h;
        add_header Pragma public;
        add_header Cacle-Control "public";

        # include vw/lucee-base-include.conf;

        location ~ \.(cfm|cfml)(.*)$ {
            proxy_pass          http://lucee_servers;
            proxy_redirect      off;

            proxy_http_version  1.1;
            proxy_set_header    Connection "";

            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;     ## CGI.REMOTE_ADDR
            proxy_set_header    X-Forwarded-Proto   $scheme;                        ## CGI.SERVER_PORT_SECURE
            proxy_set_header    X-Real-IP           $remote_addr;
        }

        break;
    }

}

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
    <Listener className="org.apache.catalina.core.JasperListener" />
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
    <Service name="Catalina">
    <Connector port="8888" protocol="HTTP/1.1"
        connectionTimeout="20000"
        redirectPort="8443"
        useHttpOnly="true"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

        <Engine name="Catalina" defaultHost="myDefaultHost">
            <Host name="myDefaultHost"  appBase="webapps"
            unpackWARs="false" autoDeploy="false">

            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                prefix="localhost_access_log." suffix=".txt"
                pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>
                <Valve className="mod_cfml.core"
                    loggingEnabled="false"
                    waitForContext="3"
                    maxContexts="200"
                    timeBetweenContexts="30000"
                />
            </Host>

            <Host name="exampleurl.de" appBase="webapps">
                <Alias>www.exampleurl.de</Alias>
                <Context path="" docBase="/opt/wwwRailo/priceBoard" useHttpOnly="true" />
            </Host>

        </Engine>

    </Service>
</Server>

Thanks in advance for taking a look!


Solution

  • Turns out that the configuration worked just as expected, but the admin registered the domain through a forwarding service and forgot to set a second setting. Because of that, somehow only nginx detected the domain the request was intended for, but Tomcat didn't and as a result, the default behavior was triggered, meaning the "welcome page".