Cannot load socket.io.js with apache proxy setup - apache

I feel like this question might be a duplicate but from all similar threads I have checked still wasn't able to find a answer.
I have vhost setup to proxy /node/ request to NodeJS/Socket.IO server.
ProxyRequests On
ProxyPass /node http://192.168.2.151:1337/
ProxyPassReverse /node http://192.168.2.151:1337/
This setup successfully serves everything from Apache, expect requests: http://domain.com/node/
Everything works fine when it comes to NodeJS.
I just can't get this line:
<script src="/node/socket.io/socket.io.js"></script>
to load socket.io.js, it always spits out what NodeJS server has to say.
The setup:
index.html is served by Apache. http://domain.com/index.html
index.html is simple HTML with script tag for loading socket.io.js (like I wrote above).
When I request http://domain.com/index.html script src is loaded but the content is NodeJS servers response instead of socket.io.js.
I have 'npm install socket.io' in the directory where NodeJS server is running from.
I have tried to serve index.html with NodeJS as well, regardless - socket.io.js content is still NodeJS responce.
Did anyone had this problem? Or could link me to an answer? :)
Cheers!

Look at this question and all of the answers at serverfault: Configuring Apache2 to proxy WebSocket?.
The problem is that mod_proxy doesn't support WebSockets and just makes it an HTTP request. You could use a different port and avoid proxying, switch to Nginx, try haproxy or use various other Apache module alternatives. For instance, mod_proxy_wstunnel is basically mod_proxy with WebSockets support. See the serverfault link above for details on all of the solutions.

Related

Scrapyd links do not work with HTTPS, just keeps loading and loading

I have scrapyd installed in Ubuntu.
I also have a website with SSL enabled, I need to make request to links like https://IP_HERE:6800/listjobs.json?project=default inside my website.
But it looks like Scrapyd does not work with HTTPS.
Even if I open link in browser it just keeps loading and loading.
But if I make request using http:// instead of https:// it works. But I want it to work with HTTPS.
I thought I need to edit my SSL conf file to work with port 6800. I did but still its not working.
Here is my SSL config file looks like.
<IfModule mod_ssl.c>
<VirtualHost *:443 *:6800>
.... and rest of confguration...
By looking at the source code of scrapyd, it uses a TCPServer from Pythons socketserver module. It is not possible to enable SSL in a Python module via the Apache config file.
What you want to use is a HTTPS-to-HTTP proxy, which wraps up scrapyd's HTTP into an HTTPS protocol. You can use Apache for that, see this tutorial from Digital Ocean or this blog post.

How to configure Apache forward to IIS

My website running on IIS 8.0.
I was install Ubuntu on another machine, and setup Apache and Varnish on it.
Now, I want how to configure Varnish and Apache when visitors access Apache that it will forward to my Website on IIS.
Please help me!!!
As your question, you need varnish and apache to send the visitor to IIS Server .
I could not understand why you need apache to send To IIS which will cause your page load slower due to unnecessary routing.
But to answer your query
in apache config:
sudo vi /etc/apache2/apache2.conf
add below
ProxyPass "/" "http://IISserverip/"
ProxyPassReverse "/" "http://IISserverip/"
hope this resolve your requirement

Drupal - Mixed content error when using ssl certificate

I had a drupal installation working fine. I tried to migrate that one on a Docker Container runing behind a nginx reverse proxy. Everything seems fine but i have some .js and .css files that can't load because in drupal they are linked with http. The error is:
Mixed Content: The page at https://proxy.xx.xx/ was loaded
over HTTPS, but requested an insecure stylesheet
http://proxy.xx.xx/sites/default/files/css/css_xE-rWrJf-
fncB6ztZfd2huxqgxu4WO-qwma6Xer30m4.css'. This request has been
blocked; the content must be served over HTTPS.
I have something like 7 of them and i can't find where those files are called in drupal or how to change the http to https.
Best regards.
Alright, so I got to work by adding the following to the Drupal settings.php:
$conf['reverse_proxy'] = TRUE;
$base_url = 'https://whatever-your-domain-is.com';
$conf['reverse_proxy_addresses'] = array('internal_nginx_proxy_ip');
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
This works for jwilder's nginx-proxy container(s) together with JrCs' letsencrypt companion container. The nginx container is handling the HTTPS/SSL (certificates) and talks HTTP with the Drupal-container internally. The Drupal container only needs to be run with the 3 ENV VARS VIRTUAL_HOST, LETSENCRYPT_HOST, LETSENCRYPT_EMAIL for everything to be set up and work its magic.
Only downside: The Drupal container's apache logs show the internal IP of the nginx proxy. But the nginx logs show the correct client IPs and Drupal apparently gets them right as well, so it's only a minor nuisance for me.
I guess the additions to the settings.php should also be applicable to custom/manual setups.
We found what was wrong. Drupal was communicating with the Nginx proxy without ssl. Some config and it was ok.

reverse proxy apache to localhost server

I've got a web app running on localhost:3000. I also have an apache server. I would like to reverse proxy the apache server so that requests to /mywebapp get forwarded to the server running on localhost:3000.
I currently have the following config at the bottom of my httpd.conf file, but I'm getting a server error when I try to access it:
ProxyPass /mywebapp http://localhost:3000
ProxyPassReverse /mywebapp http://localhost:3000
Edit - further details:
I'm running a jetty server with java -jar myapp.jar. I'd like to forward requests to an apache server listening on :80 to the jetty server.
I've got mod_proxy_http.so and mod_proxy.so enabled.
I can tell the server is running on localhost - it responds to curl with the appropriate http response. So I'm pretty sure the issue is with my apache setup, but I can't think what the problem would be.
Apache conf file in conf.d for reference: http://pastebin.com/vhXwjbQe
And I've got this in my httpd.conf:
Include conf.d/*.conf
It's hard to give a generic answer because every situation is different so here are some debugging questions to ask yourself:
if the protocol and port correct on the internal service, http and 3000.
Is the service actually listening for connections from localhost? is it running in a docker container etc that would require it to be listening on a different interface? You can check for this by looking at the output from mywebapp's logs and see if the request are making it through the proxy.
Do the paths on the internal service include the prefix that is being passed to Apache or does apache need to strip these off. if for instance mywebapp expects the path "/foo/bar" and apache's reverse proxy is sending it with the context path included "/mywebapp/foo/bar" then it will not match any path in mywebapp.

Tomcat serving URLs wrong with mod_proxy and apache

I've set up a host with apache to serve static pages and to use Tomcat to serve my web application (See this question). The static pages are server from
"http://myhost.com"
and the dynamic (tomcat) pages are server from
"http://myhost.com/myapp"
The mod_proxy makes sure the "http://myhost.com/myapp" are forwarded to tomcat server running on "http://myhost.com:8080".
The problem is that now you get the standard Tomcat introduction page on "http://myhost.com/myapp" but if you click on a local link (e.g. 'Status') on the left, it generates an URL
"http://myhost.com/manager/status" while it should generate: "http://myhost.com/myapp/manager/status"
(The same is true for webapps installed under tomcat)
What should be changed in my configuration (apache, tomcat?) to redirect my tomcat links to the right place?
Have you set the ProxyPassReverse setting in your httpd.conf. This will overwrite the HTTP Header an you'll get to the correct request on the side of tomcat.
Your URLs are mapped from:
http://myhost.com/myapp -> http://myhost.com:8080
This means that accessing the above URL will be mapped to the ROOT application in Tomcat. The ROOT application will generate pages that contain links from Tomcat's root context.
In other words, if you go to:
http://myhost.com:8080
you will get a page that contains links to
http://myhost.com:8080/manager/status
This link will work. However when that page is given back to a browser that requested it via Apache, the full URL then looks like: http://myhost.com/manager/status
I assume that you intend to deploy an application called 'myapp' to Tomcat? If that is the case the Tomcat URL for this app will be
http://myhost.com:8080/myapp
Which will also work be mapped correctly when accessed via Apache.
If you absolutely must access Tomcats root application in this way you'll have to rewrite the URLs it outputs in the pages it returns.
I've had the most success with mod_proxy_ajp. It requires mod_proxy, but works over ajp. Using it instead, your conf file looks similar
ProxyPass / ajp://localhost:8009/
See my similar question and also the answer to this question. The only fault in mod_proxy_ajp that I've found is that if I need to restart tomcat I have to force an apache restart too.