Git Product home page Git Product logo

viviotech / mod_cfml Goto Github PK

View Code? Open in Web Editor NEW
23.0 8.0 16.0 7.57 MB

Mod_cfml is a community-driven suite of programs that automatically configures Tomcat hosts to match hosts created in Apache or IIS. Mod_cfml removes the need to configure web sites twice - once in your web server and again in Tomcat - and performs this task automatically for you.

License: GNU Lesser General Public License v3.0

Java 49.81% Perl 9.37% CMake 1.47% Makefile 1.60% C 37.75%

mod_cfml's Introduction

mod_cfml

Mod_cfml is a community-driven suite of programs that automatically configures Tomcat hosts to match hosts created in Apache or IIS. Mod_cfml removes the need to configure web sites twice - once in your web server and again in Tomcat - and performs this task automatically for you.

Official Site

Installation and Configuration documentation can be found on the mod_cfml site here:

http://viviotech.github.io/mod_cfml/

Note that the previous modcfml.org site has been depreciated in favor of the GitHub site in order to better facilitate community contributions and updates.

Compiling the Apache module

See C/README.md for instructions.

mod_cfml's People

Contributors

paulklinkenberg avatar pfreitag avatar zspitzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mod_cfml's Issues

Fatal Tomcat startup error can occur in read/write race condition of context xml file

While debugging a non-responsive web VM instance, I found out that Tomcat never deployed the specific web context. (fix was, to restart Tomcat)
The main error in the Tomcat log was "Failed to process either the global, per-host or context-specific context.xml file therefore the [] Context cannot be started."

What can be read from the error log underneath, is that Tomcat tried to deploy the web context, but choked on an empty file at /etc/tomcat8/Catalina/12.34.56.78/ROOT.xml. This file is written by mod_cfml, right before deploying the context. It should not be empty.

Curently, I suspect mod_cfml allowed a second request to also write to that file. The init/deploy code should only be accessible by 1 request at a time. But this is only a suspicion currently.

Error log: (I replaced the ip address in question with 12.34.56.78)
`INFO: Server startup in 13424 ms
[mod_cfml] ERROR: java.lang.IllegalArgumentException: addChild: Child name '12.34.56.78' is not unique
Apr 01, 2019 2:49:16 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat8/Catalina/12.34.56.78/ROOT.xml
[mod_cfml] ERROR: java.lang.IllegalArgumentException: addChild: Child name '12.34.56.78' is not unique
Apr 01, 2019 2:49:17 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 1: Premature end of file.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1014)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1480)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:537)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Apr 01, 2019 2:49:17 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor /etc/tomcat8/Catalina/12.34.56.78/ROOT.xml
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1480)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:537)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Apr 01, 2019 2:49:17 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component []
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to process either the global, per-host or context-specific context.xml file therefore the [] Context cannot be started.
at org.apache.catalina.startup.FailedContext.startInternal(FailedContext.java:200)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more

Apr 01, 2019 2:49:17 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor /etc/tomcat8/Catalina/12.34.56.78/ROOT.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component []
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Apr 01, 2019 2:49:17 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat8/Catalina/12.34.56.78/ROOT.xml has finished in 207 ms`

mod_cfml checks uri rather than filename

mod_cfml doesn't trigger when a directoryIndex index.cfm directive is used, on a first request to just /, which ends up with the default welcome to lucee page on port 8888

the reason is it's checking the r->uri, as opposed to the actual file which is handling the request? i.e. r->filename

it works after any other request has triggered mod_cfml and tomcat knows about the context

https://github.com/viviotech/mod_cfml/blob/master/C/mod_cfml.c#L385

https://dev.lucee.org/t/mod-cfml-isnt-triggering-on-the-first-request/8263

It looks like we are almost doing more processing, to avoid adding the extra headers, than just adding the headers involves?

More redirect issues - index.cfm?&__&__&__&__&__&__&__

I am getting too many redirects after implementing a solution to THIS problem
"mod_jk to shows/append index.cfm?&_modcfmlredirected on page load"

I am trying to run Lucee CF with Apache 2.4 on a windows EC2 instance.

Install of both Apache 2.4 and Lucee went fine - both services come up fine and restart fine... Apache conf is pointed to a webroot - and test page comes up fine.

I have followed instructions on implementing mod_jk - but when I tested a simple index.cfm - I got this:

index.cfm?&_modcfmlredirected

I found multiple answers - that all recommended updating your 'mod_cfml-valve_v1.1.09.jar' to 'mod_cfml-valve_v1.1.10.jar'.

So I did...

And now I get this:

http://127.0.0.1/index.cfm?&__&__&__&__&__&__&__&__&__&__&__&__&__&__&__&__&__&__&__

This page isn’t working 127.0.0.1 redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

reverting to the 1.1.09 file brings back the ?&_modcfmlredirected as expected.

The code of index.cfm is simply

CF Index : 
<cfoutput>#now()#</cfoutput>

This is not a 'code' issue....

Any help is greatly appreciated.

First load of each application after server start restart appends index.cfm?

After restarting the server, or after application has expired (from configured time-out), the first load appends index.cfm to the URLs ending in /, or .cfm to URLs such as mysite.com/page.

I updated mod_cfml from 1.04 to 1.09, and then 1.10 too, and this changed to append index.cfm? to the URL.

I'm on the latest version of Lucee, 5.3.3.62, IIS 10, & Windows 10.

wrong webroot with apache virtualhosts on different ports

just trying to set up a couple of working directories with mod_cfml on windows with apache 2.4

two localhost virtualhosts, on ports 81 and 82

<Directory "c:/www/one/">
    Options Indexes FollowSymLinks
    DirectoryIndex index.cfm
    AllowOverride All
    Require all granted
</Directory>

Listen 81
<VirtualHost *:81>
    ServerName  zac-test-one
    DirectoryIndex index.cfm
    DocumentRoot  "C:/www/one/"
	
	<Proxy *>
		#Require host 127.0.0.1
	</Proxy>
	ProxyPreserveHost On
	ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</VirtualHost>


<Directory "c:/www/two/">
    Options Indexes FollowSymLinks
    DirectoryIndex index.cfm
    AllowOverride All
    Require all granted
</Directory>

Listen 82
<VirtualHost *:82>
    ServerName  zac-test-two
    DirectoryIndex index.cfm
    DocumentRoot  "C:/www/two/"
	
	<Proxy *>
		#Require host 127.0.0.1
	</Proxy>
	ProxyPreserveHost On
	ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</VirtualHost>

as you can see below, unique X-Tomcat-DocRoot / X-Webserver-Context combinations are generated

URI => /one.cfm, filename => proxy:ajp://localhost/one.cfm
Incoming header [Host] => localhost:81
Incoming header [Connection] => keep-alive
Incoming header [Cache-Control] => max-age=0
Incoming header [User-Agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3225.0 Safari/537.36
Incoming header [Upgrade-Insecure-Requests] => 1
Incoming header [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Incoming header [DNT] => 1
Incoming header [Accept-Encoding] => gzip, deflate, br
Incoming header [Accept-Language] => en-AU,en;q=0.9,en-US;q=0.8,de;q=0.7
Incoming header [X-Tomcat-DocRoot] => C:/www/one/
Incoming header [X-Webserver-Context] => zac-test-one-httpd-confl554
Handler Pattern Found => .cfm
Pattern Match TRUE: extension [.cfm] matches handler [.cfm]
Handler Pattern Found => .cfc
Handler Pattern Found => .cfml

URI => /two.cfm, filename => proxy:ajp://localhost/two.cfm
Incoming header [Host] => localhost:82
Incoming header [Connection] => keep-alive
Incoming header [Cache-Control] => max-age=0
Incoming header [User-Agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3225.0 Safari/537.36
Incoming header [Upgrade-Insecure-Requests] => 1
Incoming header [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Incoming header [DNT] => 1
Incoming header [Accept-Encoding] => gzip, deflate, br
Incoming header [Accept-Language] => en-AU,en;q=0.9,en-US;q=0.8,de;q=0.7
Incoming header [X-Tomcat-DocRoot] => C:/www/two/
Incoming header [X-Webserver-Context] => zac-test-two-httpd-confl575

but which ever virtual host gets the first request, the second one just ends up serving from the first host's docroot? have i missed something obvious?

is it that the port is missing from the the proxy:ajp url?
URI => /two.cfm, filename => proxy:ajp://localhost/two.cfm

orginally posted here https://dev.lucee.org/t/mod-cfml-woes-with-apache-on-windows/2820

Does the mod_cfml Valve really need to write mod_cfml.dat?

I was looking over the code because I got a file permission error when trying to write /var/lib/tomcat7/mod_cfml.dat on Ubuntu (using the Ubuntu tomcat7 installation).

Wouldn't it be better to store the contextRecord array in a static variable instead of in a file since the file is deleted / reset on startup anyways? I realize that this takes memory utilization but it is very small.

What do you think? If you are ok with switching to a static variable I can submit a pull request with the change.

mod_cfml Apache 2.4 VC16 build

The download for mod_cfml for Apache on Windows is a VC10 build
https://viviotech.github.io/mod_cfml/download.html

The last Windows Apache 2.4 VC10 build which is available is 2.4.23
https://www.apachelounge.com/download/VC10/

The latest version is Apache 2.4.39 Win64 which is only available for VC15 and VC14
https://www.apachelounge.com/download/

Build with the latest Windows® Visual Studio C++ 2017 aka VC15. VC15 has improvements, fixes and optimizations over VC14 in areas like Performance, MemoryManagement, New standard conformance features, Code generation and Stability. For example code quality tuning and improvements done across different code generation areas for "speed". And makes more use of modern processors and supported Windows editions (win 7 and up) internal features.

NullPointerException at org.apache.catalina.connector.Response.sendRedirect

The first redirect after creating a new contexts results in this error:

31-Jul-2019 21:07:06.082 INFO [fe-api.dev-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor [/etc/tomcat8/Catalina/fe-api.dev/ROOT.xml] has finished in [90] ms
[mod_cfml][1] Verifying context files...
[mod_cfml][1] Redirect URL => '/index.cfm?'
31-Jul-2019 21:07:06.084 SEVERE [http-nio-8888-exec-4] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
at org.apache.catalina.connector.Response.sendRedirect(Response.java:1330)
at org.apache.catalina.connector.Response.sendRedirect(Response.java:1299)
at mod_cfml.core.doRedirect(core.java:530)
at mod_cfml.core.invoke(core.java:515)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:679)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

Injecting config into the <Context>

I'm considering using an alternate Session Manager (e.g. https://github.com/magro/memcached-session-manager) for external storage of sessions and session replication. In order to do so, I have to create a <Manager> created inside the<Context> element. This currently isn't possible with mod_cfml, because it generates the <Context> and doesn't seem to have an injection feature.

  1. Is there a way to inject config into <Context> that I'm missing?
  2. How would you feel about a PR that adds this feature?

Apache execution order with mod_proxy and mod_cfml

Hi,

I've been trying to setup a Lucee + Apache stack for a while and I kept running into problems where my VirtualHost configuration wasn't passed through to the Tomcat env. Everytime I did the request I saw the welcome screen of Lucee.

Initial I thought I had wrongly configured my env and even tried to follow the instructions from here by the letter. After some debugging sessions later I noticed that Tomcat7 never received the 'X-Tomcat-DocRoot' header indicating it must be on the Apache side of it.

After narrowing down the problem I found that Apache has a certain way of handling their module execution order. I added some logs into the mod_cfml.c to check if the request is actually being passed to Tomcat7 and noticed that it never reached the hook at all. Turning off mod_proxy made the .cfm requests show up in the apache logs. Turning mod_proxy on again and these requests disappeared from my apache logs.

This all made sense since my proxy.conf looks like this and is only passing through .cfc / .cfm files.

<IfModule mod_proxy.c>
    <Proxy *>
        Allow from 127.0.0.1
    </Proxy>
    ProxyPreserveHost On
    ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</IfModule>

I thought this would be related to the execution order of Apache modules in some case and mod_proxy stopping any other modules from executing further mods. To test this I slightly modified mod_cfml.c and compiled it against 2.4. Changes can be found in a fork I made here. These changes fixed the issue I had.

I'm doing this on a machine generated by a Dockerfile running the following:

Apache2.4/10
Lucee 4.5.1.0 (Using the Lucee Installer with Tomcat7)

If required I can add my Dockerfile to this issue to reproduce the issue and a Dockerfile with the issue fixed.

Keep mod_cfml.dat in one place

Is there any way to keep the mod_cfml.dat file in one place? I have seen it mentioned that this file should live in the Tomcat install directory, however, in my experience on Mac OS, if I start Tomcat by cd'ing into the Tomcat bin directory and running the startup.sh script that is true but if I start it by using the full path in another directory then mod_cfml.dat is created in the directory where I ran the script from.

Example:

cd /Applications/Railo/tomcat/bin/
./startup.sh

works fine, the mod_cfml.dat file is created in Tomcat's bin directory, however:

cd ~
/Application/Railo/tomcat/bin/startup.sh

results in a mod_cfml.dat file in my home directory.

If this is by design, that is fine, but I wanted to make sure that 1) you were aware of this, and 2) see if there was a way we could change the Java code to prepend a specific path, perhaps the Tomcat bin directory if avaialble, in the two places that Java makes File(Input|Output)Stream references to mod_cfml.dat. This would ensure that the file stays put in the Tomcat bin directory.

Thanks!

_modcfmlredirected

Hi,
I'm using the following stack: nginx 1.6.0 & tomcat9, lucee 5.3 and mod_cfml-valve_v1.1.09.jar

At the first access (for example after restarting the server) I get this redirect:

http://www.website.com/index.cfm?&_modcfmlredirected

How can I avoid it?
thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.