Accessing RabbitMQ through webserver - apache

I have a RabbitMQ server running on an EC2 instance, and a URL address pointing to the instance configured in Route53, which I use to access the RabbitMQ web UI.
I can access the UI just fine using Nginx or Apache, but when trying to look at the page of a specific queue or exchange I receive an error saying the object was not found. This behaviour does not happen when I access the UI directly through IP:Port url.
I've noticed this is a known bug, which was addressed here -
https://fatalfailure.wordpress.com/2012/11/16/nginx-as-reverse-proxy-for-rabbitmq-mochiweb-server/
I've tried implementing the fix listed in this post, using the following Apache configuration -
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName stage-rabbithq.apester.com
ServerAlias stage-rabbithq.apester.com
ProxyPass /api http://localhost:15672/api nocanon
ProxyPass / http://localhost:15672/
ProxyPassReverse / http://localhost:15672/
</VirtualHost>
But the error prevails.
Does anybody have a solution for this error?

I've solved it, the problem was forgetting to add the following line to my site conf file -
AllowEncodedSlashes On
Hope this helps someone, someday.

Related

Apache hybris configuration to proxy pass HTTP and HTTP(S) yacceleratorstorefront (electronic store) URL to Hybris Server

I am trying to access the yacceleratorstorefront/electronics/en/?site=electronics URL from apache web server to Hybris where the electronic store URL is configured. The electronic store URL is accessible and working from any of the server in environment if apache web server is BY PASSED
http://10.0.1.141:9001 is my Hybris server.
ERROR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HTTP Status 500 - Cannot find CMSSite associated with current URL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
type Status report
message Cannot find CMSSite associated with current URL
description The server encountered an internal error that prevented it from fulfilling this request.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Any suggestion or advice is highly appreciated. Thank you in advance.
-Regards, S#BS
------------------------------------------------httpd Code below----------------------------------------------------
<VirtualHost *:80> ProxyPreserveHost On
ProxyPass / http://10.0.1.141:9001/ ProxyPassReverse / http://10.0.1.141:9001/
ServerName localhost</VirtualHost>
<VirtualHost *:443> ServerName localhost
#ProxyRequests Off #ProxyPreserveHost On ProxyPass / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics ProxyPassReverse / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics
SSLEngine on SSLCertificateFile /etc/httpd/certs/mysite.com.crt SSLCertificateKeyFile /etc/httpd/certs/mysite.com.key
</VirtualHost>
The error message indicates that you are not setting the ?site=electronics parameter at the http version of you proxy (it also seems to be missing in the proxypass setting for port 80).
I'm not an apache buff but maybe it works if you configure your proxy settings for port 80 in the same way:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://10.0.1.141:9001/?site=electronics
ProxyPassReverse / http://10.0.1.141:9001/?site=electronics
ServerName localhost
</VirtualHost>
Just some more info: Apart from the site parameter approach you can also use a host name approach.
Not sure if you have access to the hybris wiki, but here are some more details:
https://wiki.hybris.com/display/pmtelco/Using+Modulegen+to+Create+a+B2C+Telco+Setup#UsingModulegentoCreateaB2CTelcoSetup-AccessingtheStorefront
(its for Telco accelerator, but it works the same for any other storefront).
Not sure how that works together with apache, I assume you have to setup some sub domains or something.
Does it work if you try to access apache on https directly? (There it seems you have the correct url containing the site parameter).
Note: The site parameter is basically only needed for the first http request of a session. It is used to determine which storefront, i.e. BaseSite is supposed to be used. All subsequent requests (of the same session) shouldn't require the site parameter.
Hope that helps!
Your http config is fine. Your https config is wrong.
Do not put ?site=electronics or anything like that in your apache config.
The site detection works based on the URL. In the sample data you are using that is at least a regex looking for "electronics" in the hostname.
One single apache config will be able to support all sites. You do not need to specify the site. You do not need to specify /yacceleratorstorefront.
Simply edit your hosts file to include "10.0.1.141 electronics.rtfm"
Now access http://electronics.rtfm/
You can avoid adding the site in the URL by going in HMC: WCMS > Websites
Under the Properties tab, add a new URL pattern that will match your site.
Once it is done, URLs that match the site's pattern will automatically use that site.
Using URL patterns for each site will simplify the web server's configuration.

Deploying a Grails app with Tomcat on an existing site

I am trying to deploy a grails app on an existing site (mysite.org) using Tomcat with a virtual host, and I've been told I also need to use a ProxyPass and a ProxyPathReverse to the chosen port. I've successfully set up Tomcat, added the WAR file to the tomcat/default-root folder, and edited the server.xml file to include this, an exclusion for serving content to the app.
<VirtualHost *:*>
ProxyPreserveHost On
ProxyTimeout 3600
Timeout 3600
ProxyPass /interventions !
ProxyPass / http://00.00.000.000:8080/
ProxyPassReverse / http://00.00.000.000:8080/
ServerName interventions.mysite.org
</VirtualHost>
I'm not really sure where to go from here, what I want to happen is to be able to go to interventions.mysite.org and use this app. I know I need to properly configure the virtual host but I've gotten lost in guides that seem to focus on setting it up from the start rather than integrating with an existing site, which had me worried about making any changes without realising (given my lack of knowledge right now).
What should my next step be, and are there any resources I should seek out (or search terms I should use, as I'm totally overwhelmed after my attempts)?
**Edit: Is my wishing to use interventions.mysite.org rather than, say, mysite.org/interventions complicating the issue?
create a site in apache called interventions.mysite.org.conf
To create the site you can just copy the already existing site file found in the sites-available folder in your apache installation and just make edits where necessary.
You file should look like the one i have pasted below, i believe the code i have pasted below should work fine for you, just make edits to the ProxyPass and ProxyPassReverse fields to match your app installation.
Remember to enable the site by using the command below;
sudo a2ensite interventions.mysite.org.conf
and also ensure that you have i think mod_proxy enabled.
it can config just like the one below;
<VirtualHost *:80>
ServerName interventions.mysite.org
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests Off
ProxyPreserveHost On
ProxyErrorOverride On
ProxyPass / http://localhost:port/my-app/
ProxyPassReverse / http://localhost:port/my-app/
</VirtualHost>
You can also read the apache docs if you don't understand some of the config parameters. Hope that helps.
Cheers!

Running multiple root\no context web apps on single host

I have a host with a single web app and at the moment I am accessing it via www.hostnameA.com/ as the web app is deployed to tomcat/webapps as the tomcat ROOT web app.
Now I need to add another web app to my host and I also want this one to have no context either but will access it via another hostname www.hostnameB.com/ but I can only deploy one ROOT tomcat web app.
I should have added that I am using apache as well and my virtual host looks like:
<VirtualHost *:80>
ServerName www.hostnameA.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
I tried renaming the war file to webAppA and then appending that to the proxypass but it gave me a 400 error and kept appending /webAppA to the URL:
ProxyPass / http://localhost:8080/webAppA
Is there a solution to this? I dont really want to run multiple instances of tomcat on different ports just for this, is there another option?
As discussed above, most straightforward solution would be to use Apache's mod_proxy_ajp, allowing proxying and AJP forwarding at the same time. Configuration should look something like:
<VirtualHost *:80>
ServerName www.hostnameA.com
ProxyPass / ajp://localhost:8009/webAppA/
ProxyPassReverse / http://www.hostnameA.com/webAppA
[...]
...and same with B for www.hostnameB.com.

ProxyPassReverse to Tomcat adding path to URL

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.

Multiple ProxyPassReverse for a Virtual Host with identical URLs

We have a situation where we have one JBoss application that is being proxied by two Apache paths as a Virtual Host below:
<VirtualHost *:80>
ServerName localhost1
ProxyPass /abba/ http://localhost:8080/app/
ProxyPass /babba/ http://localhost:8080/app/
ProxyPassReverse /abba/ http://localhost:8080/app/
ProxyPassReverse /babba/ http://localhost:8080/app/
</VirtualHost>
The routing of /abba/ and /babba/ need to go to the same application - going forward we are using rewrites to add some parameters that the application uses to configure itself based on whether /abba/ or /babba/.
However when the application sends a redirect the ProxyPassReverse does not work as access sayfrom /babba/ gets redirected to /abba/.
I understand the reason as it's the same application - however is there are way of configuring Apache to support two difference routes (ProxyPass and ReverseProxyPass) to the same application.
Many Thanks
Have you tried duplicating the VirtualHost and changing the duplicate to server name "localhost2"?