How to configure Varnish + Nginx reverse proxy on LAMP server - apache

I have already installed LAMP server on Ubuntu (digital ocean droplet). Now I want to install Varnish + Nginx reverse proxy on it.
I have only 1 GB ram on digital ocean droplet. So, Does Varnish + Nginx + Apache is good or I should only install Nginx + Apache.
Actually website getting very good traffic. So I need to install Varnish, Nginx reverse proxy on the server for better performance.
Please guide me how can I configure this on the server.
Thanks

It depends on what exactly you want to store in your cache and whether you need any complex conditions for caching rules (like caching based on some headers, cookies, IP address, etc.)
If you only want to cache static static content, then you can simply use https://www.nginx.com/blog/nginx-caching-guide/ and mount your cache folder as tmpfs (which is placed in RAM): https://blog.wp-rocket.me/mount-folder-ram/
Then you won't need varnish in front of nginx and will still have fast cache.

Related

what's problem a cloudflare cache for Nginx origin server?

I am using two origin server for Apache and Nginx with Cloudflare CDN.
But caching does not work on Cloudflare for Nginx only.
Everytime no "HIT"
Everytime "DYNAMIC"
"Page Rules" setup for "Everything"
what is the difference between Apache and Nginx when using Cloudflare CDN?
Note: In Apache, it works very well.

AWS ELB + apache httpd + tomcat

We are currently using the "standard" architecture created by AWS OpsWorks.
We have set up AWS ELB in front of multiple machines, which sends the requests to one machine using round-robin algorithm ( we have stateless application without any cookies ). Apache httpd + Apache tomcat is installed on every machine ( everything set up and configured by AWS OpsWorks ). So Apache httpd handles the connection and then sends it to Tomcat via AJP connection.
I would like to get rid of the apache httpd.
Few reasons for that:
Easier architecture, easier configuration
Maybe slight gain in performance
Less monitoring ( need to monitor only Tomcat, but not Apache httpd )
I have checked the following thread:
Why use Apache Web Server in front of Glassfish or Tomcat?
and haven't find any reasons why I shouldn't remove apache httpd from my architecture.
However, I know that some applications have nginx in front of the Tomcat for the following reasons:
Slow clients handling ( ie worker thread of tomcat is freed, but async nginx thread sends clients )
DDoS SYN ( using SYN cookies ) protection
Questions to consider:
Does apache httpd protects from these DDoS techniques?
Does AWS ELB protects from these DDoS techniques?
Should I remove apache httpd ( given that I don't need anything from the list )? Should I replace it with nginx? Should I replace it with nginx ( taking into account that we have a DDoS protection with Incapsula )?
Any other advice/comment would be highly appreciated!
Thank you in advance!
Does apache httpd protects from these DDoS techniques?
No apache httpd does not automatically protect from DDOS attack you have to enable and configure the security modules.
Does AWS ELB protects from these DDoS techniques?
AWS ELB features are High Availability, Health Checks, Security Features By managing associated security groups, SSL Offloading for encryption etc.No AWS ELB does not protect from the DDOS and DDoS techniques.
Should I remove apache httpd?
By using Apache HTTP as a front end you can let Apache HTTP act as a front door to your content to multiple Apache Tomcat instances. If one of your Apache Tomcats fails, Apache HTTP ignores it and your Sysadmin can sleep through the night. This point could be ignored if you use a hardware loadbalancer and Apache Tomcat's clustering capabilities. This option is when you are not using AWS ELB.
Should I replace it with nginx?
If you have Incapsula for DDOS there no need to complex the process by adding nginx.

Nginx Proxy/ Apache - cache static file or duplicate to nginx server

It setup wordpress on apache server and config it runs smooth.
Now i want to setup a nginx proxy to server static files.
So i have some questions:
Do i need to duplicate uploads folder of wordpress and put in nginx server ?
Or try to cache all static file in nginx server ?
On apache server i use module deflate, expires, pagespeed, opcache. So if i add nginx proxy to server static files, should i remove the deflate, expires, pagespee module ? Because we can do this work on nginx server.
In case of using Nginx, the Apache HTTPD sever is good but redundant. Nginx can communicate to PHP-FPM directly which is the most efficient solution so far, with that option you can do:
improve performance
simplify deployment procedure
setup gzip and other headers in one place
serve static content more efficiently
reduce amount of overall memory
utilise Nginx cache (with Wordpress plugin to invalidate its cache on page content update)

Configure Varnish with SSL for Drupal 7 application

I have 2 servers, one running my Drupal 7 application through Apache on RHEL 6 and another server is running Varnish Cache. Apache is configured to run on custom HTTP port 8080. I want this application to run on 9443 port with SSL with Varnish Caching support.
I have tried Stunnel, but the site appears broken as the css are not being loaded. I have tried Nginx for SSL termination but browsers complain that there are mixed content as Drupal is generating URLs for resources with "http://".
Any help regarding this will be highly appreciated. Thanks a lot.
You problem is that according to drupal you are running http, and therefore will also return http links. which causes your mixed content issue. have you set your base_url to https?

Nginx, Apache and Plesk

I am currently trying to take some load of my Apache web server.
The idea is to let nginx handle the static files.
The procedure is simple nginx pass-> 8080 to Apache.
There is just one problem.
The server has Plesk installed, and Plesk handles the vhosts with the .include files in every vhost folder/config.
Every vhost has an different port and setup in his own .include file, and that makes it impossible to change the Apache port to 8080 on a global level.
Any ideas?
As mentioned, it's better to use latest plesk 11, because it has native nginx support and it's actually stable now.
Since Plesk 9.5 appears ability to change apache ports through /usr/local/psa/admin/bin/websrvmng check for --set-http-port and --get-http-port in this pdf
Since Plesk 10.2 there is ability to change apache port on global level through plesk database http://kb.parallels.com/11232