Connect apache and coldfusion 10 using mod_proxy_ajp - apache

I'm trying to setup my local development environment and I'm only missing one piece of the puzzle.
I was able to successfully install the following on my Mac OSX 10.7.5 x86_x64
XAMPP - http://www.apachefriends.org/en/xampp-macosx.html
ColdFusion 10 - Developer Edition
Both are running fine. I was able to pull up localhost (Apache) and localhost:8500 (ColdFusion) - my ajp connector port is 8012
Now I want to be able to pass the request to my ColdFusion from Apache using mod_proxy_ajp.
I created an index.cfm file on the wwwroot/cf directory of ColdFusion, enabled the NameVirtualHost and created a VirtualHost directive in Apache that looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
<Location "/cf">
Allow from all
ProxyPass ajp://localhost:8012/
</Location>
</VirtualHost>
After restarting everything, I get a 503 error.
Any help or pointers is much appreciated.
Thanks!

check your CF logs:
{cf_root}/cfusion/logs/coldfusion-error.log
You probably have something like this in the log:
org.apache.coyote.ajp.AjpProcessor getRealPathFromServer
SEVERE: Error in getRealPathFromConn
java.io.IOException: Socket read failed
So mod_proxy_ajp is passing the request to Tomcat, but Tomcat can't read it.
Have you tried configuring with mod_jk instead?
http://helpx.adobe.com/coldfusion/kb/coldfusion10-apache-manual-connector-configuration.html
Might not be the way you want to configure it, but it should get you up and running.

Related

Apache VirtualHost Preventing Tomcat Connection

Apache VirtualHost appears to prevent call to Tomcat.
I am attempting to setup configuration that will provide this result:
http://example.com/examples -- call Tomcat
http://example.com/examples/* -- call Tomcat
http://example.com/examples2 -- call Tomcat
http://example.com/examples2/* -- call Tomcat
http://example.com/AnythingElse -- call Apache
Server is Unix OmniOS (child of Open Solaris & Open BSD)
Installed Apache 2.4.38
Installed Tomcat 8.5.32
Installed jk 1.2.43
Apache is listening on two ports
https://localhost:80
https://localhost:8888
Confirmed that Tomcat is running and JK connection is working when calling either of the Apache listing ports
I then install the Apache VirtualHost
<VirtualHost *:80>
DocumentRoot "/cgi-bin/example.com"
ServerName example.com
</VirtualHost>
Now call to http://example.com/examples returns 404 not found instead of Tomcat.
Found it!
I just needed to add my JkMount entries inside my VirtualHost as well.

Wildfly, Tomcat, Apache and Subdomains

I have an Ubuntu server in AWS that is running multiple application servers -- a Wildfly serving up some pages and two Tomcats running a separate app.
I am trying to get subdomains working.
I have DNS's set up to point subdomain1.example.com, subdomain2.example.com. That works fine.
Wildfly is listening on port 80 (I think?), the Tomcats are listening on 8080 and 8090. The goal is to have www.example.com go to Wildfly, subdomain1.example.com go to Tomcat : 8080 and subdomain2.example.com go to Tomcat : 8090
I've found numerous posts that talk about setting up virtual hosts in Apache that should solve my problem. But I keep getting sent down rabbit holes. Some suggest adding to /opt/bitnami/apache2/bin/httpd.config and some suggest putting it in /opt/bitnami/apache2/sites-available/subdomain1.example.com.conf
My first issue: I don't think that Apache is even running. I was under the impression that Apache was baked into Wildfly, but when I execute:
service apache2 status
I get:
apache2.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Running sudo service --status-all also doesn't show it running so I think that it is not. It seems to be installed (Bitnami stack) in /opt/bitnami/apache2
Do I have to turn Apache on as part of Wildfly (and how to turn it on)? If I do, then I would assume that Wildfly is no longer getting traffic.
Second - my research tells me I need i need to enable proxy and proxy_http using a2enmod and a2ensite but I don't have these. Research suggests that all Ubuntu's will have those scripts... do they get created if I turn on Apache?
Sorry for all the noob questions.... I'm a developer without a DevOps guy. This seems like it would so common it would be baked in or there would be a definite solution that I am probably missing.
For those looking for something similar, here is the solution that worked for me.
My server is a Wildfly-Apache2-MySQL AMI image on AWS. I did not need to use a2enmod nor a2ensite as my research suggested. It seems many of those modules are already enabled by the pre-built image.
NOTE THESE INSTRUCTIONS ARE BITNAMI AWI SPECIFIC - YOUR FLAVOR CONFIGURATION MAY BE SLIGHTLY DIFFERENT
To have a subdomain point to a simple Apache text site (yada.example.com):
Create a directory in ~/stack/apache2/htdocs called yada
Add an entry to the virtual hosts configuration file (sudo nano /opt/bitnami/apache2/conf/extra/httpd-vhosts.conf)
<VirtualHost *:80>
ServerAdmin info#example.com
DocumentRoot "/opt/bitnami/apache2/htdocs/yada"
ServerName yada.example.com
ErrorLog "logs/yada-subdomain-error-log"
CustomLog "logs/yada-subdomain-access-log" common
</VirtualHost>
Modify the Apache configuration file to include the virtual hosts. (sudo nano /opt/bitnami/apache2/conf/httpd.conf):
...snip...
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.
...snip...
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
# ADDED THE ABOVE LINE
...snip...
Restart Apache (sudo /opt/bitnami/ctlscript.sh restart apache)
To make it point to a Tomcat server, add this to the httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin info#example.com
ServerName yada.example.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8090/
ProxyPassReverse / http://localhost:8090/
</VirtualHost>
Your port may differ.
FYI, I found this helpful: https://docs.bitnami.com/virtual-machine/components/apache/#how-to-configure-your-web-application-to-use-a-virtual-host
Good luck and shout out to #stdunbar for his guidance.

how to configure on Apache proxy (SSL conection) to Tomcat

I am new in Apache's world, and I need to connect a server (Ubuntu system ) located in my DMZ area to a Tomcat server (Windows server System) in my network. So I wrote on my Ubuntu Apache /etc/apache2/sites-available/default-ssl:
<VirtualHost *:443>
<Location /example>
ProxyPass http://tomcatIP:8080/example/
ProxyPassReverse https://mydomain/example/
</Location>
</VirtualHost>
I restart my Apache and on the browser doesnt display anything, however if i choose source code I can see all the php, javascript, html code.
I checked the log from Apache and there are a lot logs like this:
AH00128: File does not exits: /var/html/...
I checked my firewall and everything is correct. I don`t know why my apache doesn't search on Tomcat server. Do I need more code? on apache.conf?
Many thanks for the help
You need to configure AJP Connector on Web-Server and on Tomcat Application Server.
https://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html
Afer read documentation, I checked the Tomcat configuration and I watched that it wasn't the "tipical" Tomcat, it completly customized for Servicedesk software, and after many tries and fails I couldn't do anything, finally the costumer service told me that is impossible an Apache connection. ¬¬
Thanks anyway!!

Apache websocket setup

I'm trying to set up websocket on my local machine to test it but I simply can't get it to work, nor find any guide that actually solves it.
So to sum up, can anyone tell me what's wrong with my settings?
I'm running Ububtu 16.04 and Apache 2.4.18
I have mod_proxy and mod_proxy_wstunnel enabeled
my Apache config looks like this
<VirtualHost *:80>
ServerName socket.localhost
ProxyRequests Off
ProxyPass "/ws2/" "ws://localhost:8546/"
ProxyPass "/wss2/" "wss://localhost:8546/"
</VirtualHost>
On the client side I have this javaScript
<script type="text/javascript">
var socket = new WebSocket('ws://socket.localhost');
socket.send('Test');
</script>
And I'm running
netcat -p 8546 -l
To see any connection
And lastly I have this line in my hosts file
127.0.0.1 socket.localhost
Whenever I run the JavaScript I get the error
Firefox can’t establish a connection to the server at ws://socket.localhost/.
You javascript code should utilize the address ws://socket.localhost/ws2, since this is what you have configured in the Apache proxy configuration.
Do you actually have a websocket server running at ws://localhost:8546? You don't mention that in your description.

Apache httpd.conf - route request to different port

I have a CentOs 7.1 with Apache httpd running on port 9000.
So if i type in my browser: http://192.168.56.101:9000/ I see the Apache Testing 123 Page.
I also have a GitLab Server running on port 8888, but this port is closed by the firewall.
I want that Apache redirects traffic to http://192.168.56.101:9000/gitlab internally to the GitLab server.
I have done this in my Apache config file /etc/httpd/conf/httpd.conf:
<VirtualHost *:9000>
ProxyPass /gitlab http://192.168.56.101:8888/users/sign_in
ProxyPassReverse /gitlab http://192.168.56.101:8888/users/sign_in
</VirtualHost>
When users browse to http://192.168.56.101:9000/gitlab the login page appears (css seems broken though), but when logging in this appears:
Not Found
The requested URL /users/sign_in was not found on this server.
Is this something that is configurable with Apache and if so how?
Do I need to use some sort of Url-Rewriting, if yes which and how to get started?
All the links in gitlab will presume you are pointing at the original server.
So you need to look at mod_proxy_html to also replace these links in the HTML:
https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html