I am trying setup TeamCity webserver on a server run Apache Proxy.
I added Add this to my Apache conf file
ProxyPass /TeamCity http://localhost/TeamCity
ProxyPassReverse /TeamCity http://localhost/TeamCity
And
added the Context to my TeamCity conf server.xml file in the Host section
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
docBase="C:\TeamCity\webapps\ROOT"
debug="1"
reloadable="true" > </Context>
Anyone know why I still get ""Method GET not implemented (try POST)"?
What is that actually mean?
I'm not sure how this is going to work.. It looks like you're trying to proxy http://your-server/TeamCity to http://localhost/TeamCity, unless your apache is on a different port..?
I've just implemented the a ProxyPass for my TeamCity install. My <Context> looks like:
<Host ...>
<Context path="/build" docBase="../webapps/ROOT"></Context>
</Host>
..Giving TeamCity the root URL of http://localhost:8111/build - See here for the apache doco on the tag. Without this, TC's Tomcat would redirect you to http://your-server/login.html instead of /build/login.html (results in a 404).
My httpd.conf contains (in the mod-proxy section):
ProxyPass /build http://localhost:8111/build
ProxyPassReverse /build http://localhost:8111/build
Which will proxy the requests and responses through /build to the new TeamCity URL. Works for me!
Related
I have got apache 2.4, and 1 tomcat (connector port - 8081 and AJP - 8009) server (both on same linux box) on which I have an application folder named 'MyApp' in webapps directory.
Tomcat direct URL is - http://localhost:8081/MyApp/MyApp --> This links loads fine and displays the images, jquery and js works fine.
I am proxying all the requests to tomcat from apache using mod_proxy as mentioned below -
ProxyPass /MyApp ajp://localhost:8009/MyApp/MyApp
ProxyPassReverse /MyApp ajp://localhost:8009/MyApp/MyApp
Now, when I try to access it through web server URL, the URL loads but the images, css, jquery, which are inside the /u01/tomcat/webapps/MyApp directory doesnt work.
If I try to load the direct URL of the image, for example - http://localhost/MyApp/images/logo.jpg it doesnt work,
In the body of the image, I see -
HTTP Status 404 - /MyApp/MyApp/images/incidentReport.jpg
See above line, it is adding one more ''MyApp' to fetch the image
On the other hand, the tomcat URL [ localhost:8081/MyApp/images/logo.jpg ], loads fine.
What could be the issue? The developer of the application has designed it in such a way that it should work with a double 'MyApp' i.e. localhost:8081/MyApp/MyApp
What else do I need to do either on webserver/tomcat in order to make this work?
You need to follow these steps:
Step 1: Before configuring Apache, you should enable the necessary modules.
a2enmod proxy
a2enmod proxy_http
Step 2: Next, you are going to modify the default configuration file 000-default.conf inside /etc/apache2/sites-enabled to set up "proxying" functionality.
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8081/
ProxyPassReverse / http://0.0.0.0:8081/
ServerName localhost
</VirtualHost>
Step 3: Next, you are going to modify the server.xml file.
<Host name="www.drew-jocham.com" appbase="webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="resumesite_log." suffix=".txt"
pattern="common"/>
<Context path="" docBase="/MyApp/MyApp" debug="0" reloadable="true"/>
</Host>
Once you are done with your configuration, you will need to restart the cloud server for the changes to go into effect. Execute the following command to restart Apache: service apache2 restart
And that’s it!
Read more: https://medium.com/#ldclakmal/deploy-a-java-web-application-in-digitalocean-882226dcdbd5
I used apache proxy support in tomcat to remove the port number from url. Here is what I did,
In http.conf file I added
LoadModule proxy_module mod_proxy.so
ProxyPass /alfresco http://localhost:8080/alfresco
ProxyPassReverse /alfresco http://localhost:8080/alfresco
In server.xml file of tomcat
<Connector port="8080" ...
proxyPort="80"/> (I didn't give proxy name)
Now I am able to access the web application using http:\\localhost/alfresco in my machine. But when I try this from other machine in my lan using http:\\machine1\alfresco I am getting page cannot be displayed error. But if I try http:\\machine1 I am getting It works page of apache. What went wrong?
Previously I am able to use the application from other machine.
I removed the proxy port="80" in server.xml file and now its working
I'm running Railo 3 in Tomcat 6.0.32. The tomcat server is fronted by Apache 2.2.20. Tomcat and Apache are pre built binaries from openCSW. Railo is just the latest build war deployed in tomcat's autodeploy dir webapps.
Everything is working fine when I try to access railo and content on the tomcat server.
It fails however, when railo on tomcat redirects me to itself. Mostly, when a cfm script uses the CGI.script_name, it will be returned wrong.
On the Apache side, the content is available on www.hostname.com. Apache redirects the user to tomcat through AJP on www.hostname.com:8009/railo/content.
A script on tomcat (taken from open OAuth example) is available at:
/opt/csw/share/tomcat6/webapps/railo/content/oauth_test/examples/admin_consumers.cfm
When I access it and try to perform some action, it calls itself with a few parameters, but at that point, railo dumps out an error, complaining that the file can not be found:
Page /content/railo/content/oauth_test/examples/admin_consumers.cfm [/opt/csw/share/tomcat6/webapps/railo/content/railo/content/oauth_test/examples/admin_consumers.cfm] not found
As you can see railo added twice the relative path from tomcat: /railo/content/railo/content
This is my configuration for the virtual host in Apache:
<VirtualHost *:443>
ServerName www.hostname.com
DocumentRoot "/opt/www/hostname/htdocs/"
ProxyRequests Off
<proxy *="">
Order deny,allow
Allow from all
</proxy>
ProxyPass / ajp://www.hostname.com:8009/railo/content/
ProxyPassReverse / http://www.hostname.com:8888/railo/content/
</VirtualHost>
I tried several variant for the ProxyPassReverse directive, but with no luck so far. Based on extensive searches on the web (The Mystery of ProxyPassReverse), I tried this for the proxypassreverse:
ProxyPassReverse / ajp://www.hostname.com:8009/railo/content/
ProxyPassReverse / http://www.hostname.com:8888/railo/content/
ProxyPassReverse / http://localhost:8888/railo/content/
ProxyPassReverse / https://www.hostname.com
The tomcat server also has a virtual host defined like this:
<Host name="www.hostname.com">
<Context path="" docBase="/opt/csw/share/tomcat6/webapps/railo/content" />
</Host>
But everytime, I always get the error from Railo.
Has anyone ever seen this problem with Railo, or CGI, and has an idea how to fix it?
You are specifying "/railo/content" twice. Once in your "docBase" attribute and again in your Proxy attributes. So, requests being proxied through Apache are going to have "railo/content/" twice in their request paths because you have it listed twice: once in Apache, another time in Tomcat.
Try leaving off the /railo/content/ in your ProxyPassReverse attribute:
ProxyPassReverse / http://www.hostname.com:8888/
This will let the Tomcat config add the /railo/content/ bit all by itself.
I have multiple Tomcat servers. In each tomcat I am loading all images. I want to move the images from Tomcat to Apache and access the images from there.
My question is: is there any configuration to get the images in a Java web application from Apache instead of Tomcat?
I don't think so - images are shown by resolving their URL, and in most cases it is relative to the current page.
But you can use mod_proxy (or mod_jk) to use all your tomcats through Apache.
Hide your tomcat servers behind an apache server and then you can do something like this:
<VirtualHost www.example.com:80>
ServerName www.example.com
DocumentRoot /var/www/html
ProxyPass /img !
ProxyPass / ajp://localhost:1234/
</VirtualHost>
Apache will serve /img from /var/www/html/img and other requests will be sent to tomcat. This configuration needs mod_proxy_ajp apache module to be active. Tomcat must listen to AJP requests on the given port, use:
<Connector port="1234" protocol="AJP/1.3" redirectPort="8443" address="127.0.0.1" URIEncoding="UTF-8" />
And configure tomcat to serve www.example.com or the default virtual host.
<Host
name="www.example.com"
appBase="/path/to/tomcat/apps/www.example.com"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false"
/>
or
<Host
name="localhost"
appBase="/path/to/tomcat/apps/www.example.com"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false"
/>
Deploy your webapp to /path/to/tomcat/apps/www.example.com/ as ROOT.war, this should be enough to have the whole setup up and running.
I've got a tomcat instance with several apps running on it... I want the root of my new domain to go to one of these apps (context path of blah).. so I have the following set up:
<Location />
ProxyPass ajp://localhost:8025/blah
ProxyPassReverse ajp://localhost:8025/blah
</Location>
it kinda works... going to mydomain.com/index.jsp works except the app still thinks it needs to add the /blah/ to everything like css and js.. is there something I can do without deploying the app to ROOT or changing the tomcat server config? I'd like to keep all this kind of thing on the apache side, if it's possible.
I'm thinking I may not be understanding the proxypassreverse directive..
If you're wanting to server the app the /, Tomcat expects the app to be mounted at /, and have the name of ROOT. At least that's how I've always handled the situation personally. Even if you just symlink the app into ROOT, that should mitigate your problems. If you have an app placed in ${tomcat_home}/webapps/newapp, then Tomcat deploys it with a context of /newapp. At least, that's been the case in my history. Also, not sure if it matters but I've always used:
ProxyPass / ajp://localhost:8025/blah
ProxyPassReverse / ajp://localhost:8025/blah
it looks like this is kind of a pain in the rear.
apache is literally rewriting pages as it serves them...
I think I'll go a different route.
If you configure hosts on the Tomcat side as well then you can proxy to them and eliminate the context path for non-root webapps--in Tomcat server.xml:
<Host name="myhost">
<Context path="" docBase="/path/to/files" />
</Host>
And on the Apache side:
<VirtualHost *:80>
ServerName myhost
ProxyPass / ajp://myhost:8009/
ProxyPassReverse / ajp://myhost:8009/
</VirtualHost>
Hope that helps.