Hi guys I'm a complete novice when it comes to Apa...
# lucee
m
Hi guys I'm a complete novice when it comes to Apache tomcat so apologies in advance. I need to rewrite a rule so that the site incorporates this format: https://mydevmachine.homeproject.com/index.cfm?fuseaction=home.home FROM THIS: http://127.0.0.1:8888/Myproject/Lucee/Fusebox/realtime/currentbuild/index.cfm?fuseaction=home so this bit mydevmachine.homeproject.com needs to replace this bit 127.0.0.1:8888/Myproject/Lucee/Fusebox/realtime/currentbuild/ essentially i need to create a similar thing as is done in IIS and using a DNS in the host file (e.g. 127.0.0.1 mydevmachine.homeproject.com) but no idea how to do this in Apache I may need to add SSL - again how can this be done using Apache Can anyone help?
s
Does it have to be Apache? This can all be done in Apache, but NGINX is a lot easier to deal with if you're not too far down the Apache path
m
have to use Apache as per powers of be šŸ˜ž
a
if you are using commmandbox - then this is useful- https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/url-rewrites in terms of the server rewrite - this page in Tuckey guide has examples - https://tuckey.org/urlrewrite/manual/4.0/guide.html search for the section 'mod_rewrite vs urlrewrite filter'
s
^^^ yup you could bust both of those up to being done in Undertow
Apache isn't that hard, I just haven't used it in ages. but somebody here will know
šŸ™ 1
m
not using commandbox just standard lucee
a
ok. well these 3 steps will get Tuckey working for you.. at top of here - https://www.tuckey.org/urlrewrite/ then your rules are almost the same as IIS -. something like this - only you need to tweak it a little
Copy code
<rule>
    <name>Move Homedirs to Different Webserver</name>
    <from>^/~(.+)</from>
    <to type="redirect" last="true"><http://newserver/~$1></to>
</rule>
m
@Anders Lars Thanks! Do i need to install Tuckey and configure with Lucee? How does it work?
s
You want Apache rewrite rules. Not Tuckey. you probably could figure out a way to use Tuckey with Apache but it's redundant
m
So where do the rules go in Apache - is it server.xml?
e
There is a reason the FAA. which runs one of the busiest sites in the world, uses Tomcat for ColdFusion. @mauzer As I read through the response list, and I want to make sure I have this right. You have just Lucee installed on Lucee installer or Lucee running as a WAR in tomcat?
My suggestion is Apache 2.4 HTTPD + Tomcat + Lucee. In which case, you would create a VHOST in Apache 2.4. In the Vhost section, you would add roughly the following" <VirtualHost *:80> ServerName mydevmachine.homeproject.com DocumentRoot /var/www/html # Enable proxy and rewrite modules ProxyRequests Off ProxyPass / http://127.0.0.1:8888/Myproject/Lucee/Fusebox/realtime/currentbuild/ ProxyPassReverse / http://127.0.0.1:8888/Myproject/Lucee/Fusebox/realtime/currentbuild/ <Location /> RewriteEngine On RewriteCond %{QUERY_STRING} fuseaction=(\w+) RewriteRule ^index.cfm$ /index.cfm?fuseaction=%1 [QSA,NC,L] </Location> </VirtualHost>
m
@Evil Ware Thanks so much šŸ™. I've now installed commandbox and running a lucee engine version 5.4.3.2 .How do i do the same thing you have explained above in commandbox. Sorry to mess you about. Was having some additional issues with the standard install so decided to try it in commandbox instead. If you could let me know how to do this in commandbox be very grateful
a
if you have commandbox running the site - then the link i sent above https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/url-rewrites has simple steps to get rewrites up and running
šŸ™ 1
e
Maybe @bdw429s or @lmajano at Ortus can help you out on this. They have seminars, books, and support for their unique brand of coldfusion-related items.
šŸ™ 1
b
> I need to rewrite a rule so that the site incorporates this format: > https://mydevmachine.homeproject.com/index.cfm?fuseaction=home.home > > FROM THIS: > > http://127.0.0.1:8888/Myproject/Lucee/Fusebox/realtime/currentbuild/index.cfm?fuseaction=home It sort of sounds like you're trying to do something rewrites aren't normally used for. If you want to use CommandBox to start the site, you may find it simpler to just start the site in the folder where the code lives!
I would recommend a simple server rule, which is a different feature from Tuckey. Tuckey is sadly Java abandonware and I"m deprecating it in CommandBox 6 in favor of Undertow's built in predicate language (or Server Rules as I call them)
Hmm, looking even further at your rewrite example, it doens't even make any sense. You're wanting to replace the host and the port?? Why aren't you simply • starting the local server on the port you want to use • starting the local server on the host name you want to use (the
commandbox-hostipdater
module will keep your
hosts
file fixed up) • Pointing the web root at the folder of code that's the web root I don't understand why you'd start a local server on the wrong port, hostname, and folder and then try to patch it over with rewrites
Just doing
Copy code
cd /path/to/Myproject/Lucee/realitme/currentbuild
install commandbox-hostupdater
start port=80 host=<http://mydevmachine.homeproject.com|mydevmachine.homeproject.com>
while running as administrator (to allow the hosts file to be edited on the fly) and you should be good to go.
And if you want SSL, just add
SSLPort=443
to the start command and you'll get a self-signed cert you can tell your browser to ignore.
Now, all that said, I'll show a quick rewrite example just so you can see what it does, but I'll add you can't rewrite the hostname or port. server.json
Copy code
{
  "web": {
    "rules": [
      "equals-nocase( %{LOCAL_SERVER_NAME}, '<http://mydevmachine.homeproject.com|mydevmachine.homeproject.com>' ) -> rewrite( '/Myproject/Lucee/Fusebox/realtime/currentbuild/%{RELATIVE_PATH}' )"
    ]
  }
}
https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/server-rules/rule-examples
@mauzer
m
@bdw429s Yes the server is started where start the site in the folder where the code lives. Its a bizarre setup - hard to explain over Slack but its a very odd setup. Was built in fusebox. I will try out your suggestions. Thanks ever so much šŸ™šŸ™
@bdw429s Basically what I am trying to achieve is what you would do when you add an entry to the hosts file. When I set up a site in IIS I would bind it to the DNS entry in the host file you find in Windows C:\System32\Drivers\etc\hosts So e.g. 127.0.0.1 myprojects.com Does that make sense? So when you run in the browser this is what you will see it in the URL resolving to: https://myprojects.com/index.cfm
b
Do you have hundreds or even dozens of these sites? If not, is there a compelling reason why you're not just starting a CommandBox server in each web root? I'm not really following what the issue is.
CommandBox with the host updater module will • start up sites anywhere you want • on any port you want • on any host name you want • and update your hosts file for you What exactly are you missing at this point for what you need?
m
no just the on @bdw429s i just want to use a DNS like myprojects.com instead of 127.222.123:8888 thats it really
b
So... you're good to go with CommandBox then?
m
yep thanks @bdw429s and everyone for your help