Question

TL;DR: request to example.com/static/js/ is handled by Ngnix, while request to example.com/dynamic/category.php is processed by Lighttpd (Apache). How to do this, if it is possible?

I have a website which contain a lot of static content, like cached images, stylesheets and JavaScript. I am using SSL for majority of the content. I was thinking of changing the current setup of Lighttpd for HTTP and Apache for HTTPS, by using Lighttpd for both HTTP and HTTPS, however I was also thinking of serving static files with something like ngnix, which is perfect for such content with only one working thread. Can Lighttpd or Apache be configured to ignore processing a request, while Ngnix take requests only from one directory and its sub directories?

Was it helpful?

Solution

When an application opens a port (in this case 80/443), it owns that port exclusively. Things like the url path aren't received until after the client establishes a connection, then it sends it as part of the HTTP request.

You could do something like configure a reverse proxy for certain paths in lighttpd to go to a different port which nginx owns, but this will still push all the data through lighttpd and just use more resources than having lighttpd serve it directly.

You could also just run nginx on a different port and change all your static content urls to have that port, but I'm not sure how that might affect things like javascript domain restrictions etc. (This could also be done by configuring lighttpd to serve 301/302's for these url's, but the same concerns persist)

Personally I've found lighttpd is just as fast as nginx at serving static content, though what you're doing is cool, is it necessary?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top