serve cache/html pages created by wp-super-cache using lighttpd - apache

Currently I have lighttpd configured as a reverse proxy of apache. Lighttpd listens on the public IP while apache listens on 127.0.0.1. Lighttpd passes non-static contents to apache using the configuration
$HTTP["url"] !~ "\.(js|css|gif|jpg|png|ico|txt|swf|html|htm|gz)$" {
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 80 )))
expire.url = ( "/" => "access 5 minutes")
}
This simple setup works just fine with a vanilla wordpress install. Static files are being served by lighttpd while everything else is served by apache.
I want to take it to the next level so I installed wp-super-cache so that cache/html version of pages are created. The wp-super-cache plugin has been installed properly and its modification to the htacess file has been properly applied. I used the mod_rewrite mode of wp-super-cache and the custom permalink structure of wordpress is /%category%/%postname%.html. All works great. Cache/html pages are being created and served. There is just one little problem. It will only work if I remove the html file extesion in the above configuration. This means apache will serve the cache/html files and not lighttpd. One solution that I thought of is to have simliar rewrite rules on lighttpd when accessing html files. I do not know if it will gonna work but I searched for it anyway. I found http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/ (you may need google cache to access it because it was not working today, but yesterday it did) thinking it may be the solution but the bad news is I am using a rpm based distro and the rpm repo that I use does not have mod_magnet for lighttpd. I searched for other repos that offer lighttpd with mod_magnet but found none. So I cannot use the one solution that I have found because my lighttpd does not have mod_magnet functionality.
What should I do to make lighttpd serve the cache/html files that were created by wp-super-cache? Is this possible?
Thanks!

I know, it's a little bit late, but you could try my version of rewrite.lua script for WP Super Cache. It works just like it must work. https://gist.github.com/1258096

Related

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.

Redirecting to Amazon EC2 AMI Instance

I'm trying to redirect a router to a certain PHP page stored on what I think is CentOS on my AMI (Amazon Machine Image). I've done a bit of research and have found that other people were having the same problem: I've looked here, and here and what I got was that I need an elastic IP for the instance that has the page I want to redirect to, but I already have that.
I've tried ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page, as well as (just the IP) xx.xxx.xxx.xxx/root/path/to/page and nothing seems to work. I'm so confused. I don't need a particular domain to redirect to my AMI so I don't need to map my domain's DNS to the elastic IP.
Okay, so I figured out the problem with the redirection. Essentially, I have Apache running on my CentOS AMI. As Apache, I think, handles most if not all HTTP requests, the request for the particular page on my AMI was being handled by Apache. What I did was that I looked in the configuration files of Apache on the AMI which are under etc/httpd/conf on CentOS at least (I don't know about other distributions), and opened httpd.conf (full path: /etc/httpd/conf/httpd.conf).
I looked for the particular line that had the DocumentRoot (this line sets the directory from which Apache will serve files) directive and saw that it had "DocumentRoot "/var/www/html".
What I was doing wrong was that my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page instead of just ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/page because I didn't know Apache was automatically appending /var/www/html before /page.
So since my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/page, when Apache was getting the request it would append another /var/www/html and look in ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/var/www/html/page.

nginx and .htaccess are working together, is this possible?

I am encountering an odd situation that appears to be to good to be true. I have a vps set up with nginx installed/activated for a couple of test domains.
From what i have read, the .htaccess files don't work with nginx. But apparently the .htaccess file/directives are working for me under nginx.
I verified this by going to netcraft.com and it shows that the webserver is nginx, ab bench also shows nginx as the webserver. But the .htaccess file still can be read. For example, I can deny/allow access, or redirect using the .htaccess file.
Am I misunderstanding the information? nginx webserver can still read .htaccess files and execute directives?
Yea it's possible but there's a trick, the server has both apache and nginx installed, nginx listens to port 80 and apache listens on any other port, nginx would serve the assets directly ( CSS, JS, HTML, etc ) and pass the PHP or whatever app it is to apache, reduces the load on apache a bit, but consumes a little bit more memory because you have 2 servers running.

Cannot load socket.io.js with apache proxy setup

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.

lighttpd rewrite script running on port to same domain for XSS?

I am running freeNAS7 / lighttpd with some perl scripts that run on various ports localhost:5000, or localhost:8080 for example.
Now i tried to add cross-domian policy to the header but i cant get it to work, because most likley I am doing it incorrectly.I am not familiar with perl, if it were PHP then its pretty easy adding a header.(in terms of me understaning where to put it)
I was just thinking is there a way to rewrite for example something like
localhost/sabnzdb to display localhost:8080/ so that i can use client side to manipulate the iframe.
In lighttpd it's possible through mod_redirect. You can read about it here.
url.redirect = ( "^/sabnzdb$" => "http://localhost:8080" )
and put that in your localhost vhost (if you use vhosts) otherwise any place in your config should be ok.