请求Tomcat的所有东西而不是所需的主机

时间:2015-07-09 11:03:41

标签: tomcat nginx railo lucee

在OpenSuse VM上设置Nginx和Lucee的新安装后,我现在已经达到了可以通过内部IP和Tomcat端口访问Lucee管理员的程度,但是如果我尝试访问小测试我已经设置好了,我最终选择了全能,这意味着Lucee的欢迎页面。

这可能是非常简单的事情,但我经常忽略可能导致它的细节,所以我希望你们中的一个能指出我正确的方向。 在删除了我已经推荐过的所有东西之后,这里是server.xml和nginx.conf文件的精简版本,而没有看到任何区别。

基于域的主机块和已定义的上游可以让以后更容易添加其他站点。

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>

先谢谢你一起来看看!

1 个答案:

答案 0 :(得分:0)

原来,配置工作正常,但管理员通过转发服务注册了域,忘了设置第二个设置。因此,只有nginx才能检测到请求所针对的域,但是Tomcat没有,因此触发了默认行为,这意味着&#34;欢迎页面&#34;。