Reverse proxy styles missing - apache

https://httpd.apache.org/docs/current/mod/mod_proxy.html
According to this referral i have implemented reverse proxy in my apache server.
ProxyPass "/foo" "http://foo.example.com/bar"
ProxyPassReverse "/foo" "http://foo.example.com/bar"
Pages from the origin server is fetching but styles are missing.I have loaded the following modules in httpd.conf file.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Anyone have an idea what i am missing?

We need to give reverse proxy matching to the css/js file directories also.
ProxyPass "/foo/static/css or js" "http://foo.example.com/static/css or js directory"
ProxyPassReverse "/foo/static/css or js " "http://foo.example.com/css or js directory"

Related

Rundeck running behind apache proxy does not show "Resource Node Models"

I have a rundeck server which is running on server A with 10.10.100.120 VIP. I configured also a proxy on Server B having ip address 192.168.38.205.
So, Proxy server redirects incoming traffic to VIP:4440 in order to access Rundeck application.
To get there I have 2 options; Using application's VIP or Server B's ip address (proxy server).
Application server is a Centos 7, running Rundeck 3.0.22
Proxy server is a Centos 6 running apache 2.2
Here is my httpd configuration on proxy server:
<VirtualHost *:80>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://10.10.100.120:4440/
ProxyPassReverse / http://10.10.100.120:4440/
ServerName localhost
</VirtualHost>
Proxy modules loaded:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
I followed instructions here:
From Digital ocean's proxy guide!
The problem is :
When I access the application from proxy and click on "Resource Model" tab in order to add node file under project > project settings > edit nodes, new window does not appear.
Normally, It should appear, by this way I could select the model that I want to use as node file.
Expected result:
From_rundeck_Server1
From_rundeck_server2
Proxy server problem:
From_proxy_server1
From_proxy_Server2
That's a Known Issue, to solve it change the grails.serverURL (rundeck-config.properties file usually at /etc/rundeck/rundeck-config.properties) value from "localhost" to your server hostname. Check this: https://groups.google.com/d/msg/rundeck-discuss/I94cVxK_6kQ/0a3PPyygAwAJ

Reverse Proxy on Apache

I am naive to apache and network management. I have GeoServer hosted on one of my virtual machine which works correctly by the URL as localhost/geoserver . Also, I have successfully mapped one link say abc.ac.in/pqr/ (Link changed) to the localhost of virtual machine displaying the index.html of apache. But when I try to access abc.ac.in/pqr/geoserver then I get an error as /geoserver was not found on this server. Also, the link gets changed to abc.ac.in/geoserver.
I have used the reverse proxy as below in the httpd conf of apache as below:-
<IfModule proxy_module>
ProxyPass "/geoserver" "http://localhost:8080/geoserver"
ProxyPassReverse "/geoserver" "http://localhost:8080/geoserver"
</IfModule>
and uncommented below lines:-
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Please let me know whether is this the issue from configuration side or related to mapping from network side and the possible workaround if any.

Syntax for X-Forwarded_server for Apache

Can anyone let me know the syntax for the X-forwarded-Server,X-Forwarded-For and X-forwarded-Host in httpd.conf file.
My requirement is I am using an Apache server which has Siteminder webagent associated to it and I want to forwarded the proxy server name to Siteminder policy servers,can anyone please help on how to achieve it.
Thanks
These headers are added when you use the mod_proxy_http module. First, check for these modules in httpd.conf file
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then do something like this in your server.conf file.
ProxyPass /app1/ http://internal1.example.com/
ProxyPass /app2/ http://internal2.example.com/
Here is the Apache doc for the same.
https://httpd.apache.org/docs/current/mod/mod_proxy_http.html
You can add the headers to the reverse proxy by :
ProxyPassReverse "/mirror/foo/" "http://backend.example.com/"

Apache Proxy: No protocol handler was valid

I am trying to proxy a subdirectory to another server. My httpd.conf:
RewriteEngine On
ProxyPreserveHost On
RewriteRule .*subdir/ https://anotherserver/subdir/ [P]
The problem is that Apache is always logging this:
AH01144: No protocol handler was valid for the URL /subdir/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://localhost/
So after searching the internet, I have activated these modules:
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule rewrite_module modules/mod_rewrite.so
(I know that I don't need all of them but I just activated them to be sure I am not missing one)
But this error still appears and clients get a HTTP 500.
How can I fix this?
This can happen if you don't have mod_proxy_http enabled
sudo a2enmod proxy_http
For me to get my https based load balancer working, i had to enable the following:
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
For my Apache2.4 + php5-fpm installation to start working, I needed to activate the following Apache modules:
sudo a2enmod proxy
sudo a2enmod proxy_fcgi
No need for proxy_http, and this is what sends all .php files straight to php5-fpm:
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost"
</FilesMatch>
In my case, I needed proxy_ajp module.
a2enmod proxy proxy_http proxy_ajp
This was happening for me in my Apache/2.4.18 (Ubuntu) setup. In my case, the error I was seeing was:
... AH01144: No protocol handler was valid for the URL /~socket.io/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
The configuration related to this was:
ProxyPass /~socket.io/ ws://127.0.0.1:8090/~socket.io/
ProxyPassReverse /~socket.io/ ws://127.0.0.1:8090/~socket.io/
"No protocol handler was valid for the URL /~socket.io/" meant that Apache could not handle the request being sent to "ws://127.0.0.1:8090/~socket.io/"
I had proxy_http loaded, but also needed proxy_wstunnel. Once that was enabled all was good.
To clarify for future reference, a2enmod, as is suggested in several answers above, is for Debian/Ubuntu. Red Hat does not use this to enable Apache modules - instead it uses LoadModule statements in httpd.conf.
More here:
https://serverfault.com/questions/56394/how-do-i-enable-apache-modules-from-the-command-line-in-redhat
The resolution/correct answer is in the comments on the OP:
I think you need mod_ssl and SSLProxyEngine with ProxyPass – Deadooshka May 29 '14 at 11:35
#Deadooshka Yes, this is working. If you post this as an answer, I can accept it – das_j May 29 '14 at 12:04
I am posting an answer here, since I had the same error message for a different reason.
This error message can happen, for example, if you are using apache httpd to proxy requests from a source on protocol A to target on protocol B.
Here is the example of my situation:
AH01144: No protocol handler was valid for the URL /sockjs-node/info
(scheme 'ws').
In the case above, what was happening was simply the following.
I had enabled mod proxy to proxy websocket requests to nodejs based on path /sockjs-node.
The problem is that node does not use the path /sockjs-node for websocket requests exclusively. It also uses this path for hosting REST entrypoints that deliver information about websockets.
In this manner, when the application would try to open http://localhost:7001/sockjs-node/info, apache httpd would be trying to route the rest call from HTTP protocol to to a Webscoket endpoint call. Node did not accept this.
This lead to the exception above.
So be mindful that even if you enable the right modules, if you try to do the wrong forwarding, this will end with apache httpd informing you that the protocol you tried to use on the target server is not valid.
In my case, all modules were correctly set up (https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension is a good starter) & I had the redirection working for a base url, let's say /mysite/
but I got the errors for any child ULR, let's say /mysite/login/
http://reverse-proxy.dns.com/mysite/ was properly redirected to the remote servers while http://reverse-proxy.dns.com/mysite/login/ failed at the Apache2 reverse proxying with OP's error message.
The issue was the ending / character in the proxypass directive "/mysite/". Working configuration for child URL is :
<Proxy balancer://mysite_cluster>
BalancerMember http://192.x.x.10:8080/mysite
BalancerMember http://192.x.x.11:8080/mysite
</Proxy>
<VirtualHost *:80>
[...]
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/mysite" "balancer://mysite_cluster"
ProxyPassReverse "/mysite" "balancer://mysite_cluster"
</VirtualHost>
Trailing / truly are tricky.
I tried to get an uwsgi:// working, but somehow the manual thought it was clear to me that I actually needed mod_proxy_uwsgi. It was not. Here is how you do it: How to compile mod_proxy_uwsgi or mod_uwsgi?
For me all above-mentioned answers was enabled on xampp still not working. Enabling below module made virtual host work again
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so

How to create a proxy with apache 2.2?

I have a web app deployed on Tomcat. So my web is reachable with the url http//localhost:8080/myapp. Tomcat is install on my computer. I've installed Apache 2.2 (xampp) because i want to make a proxy. My aim is to build a proxy in order to have the following use case :
1. http://127.0.0.1:8080/myapp => displays my web app(as now)
2. http://mysuperapp.com/myapp => displays my web app ( here the http request is handled by my http://localhost:8080/myapp and the navigator always displays url http://mysuperapp.com/myapp).
Here is the configuration i use :
httpd.conf :
...various non-proxy-related modules omitted...
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName mysuperapp.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyPassReverseCookieDomain localhost mysuperapp.com
ProxyPreserveHost On
</VirtualHost>
When i try the url mysuperapp.com/myapp i cannot see my webapp. Is it something wrong ?
I'm assuming that mysuperapp.com correctly resolves to the computer that apache is running on? Just by mentioning a server name in apache's config, doesn't make it accessible under that name.
Is Apache running on the same computer as tomcat? If not, you can't use http://localhost:8080/ but will have to give the name your tomcat is accessible to Apache under (e.g. log in to the Apache-running computer and access your webapp from a browser there. If it's a headless server, use lynx or w3m - those are shell-based (text-mode) browsers.
If it's not any of these reasons, please specify "I cannot see my webapp" further: What can you see instead?
Edit: I've seen you've made some (moderator-rejected) edits to this answer: You should add these comments as "comments" below this answer.
From those edits I have the feeling that you'll have to work on the DNS side - e.g. you'll need to figure out how to make your Apache available under mysuperapp.com: So far you have configured it to reply correctly if it has been reached under that domain name, but it seems that the general name resolution does not point to it: Try ping mysuperapp.com. If that doesn't resolve to the IP-address of your Apache, you don't need to worry about anything else.