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

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)

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.

Redirect from a URL to a other server

I have the following question that I do not know how to solve it in the most efficient way.
I have two servers, one with Apache where I have a Wordpress instance responding for port 80, and on another server I have a Wildfly with another application listening on port 8080. The Wordpress that I have configured on the Apache server, responds to the URL http://www.somedomain.com What I'm not so clear about is how to do when a request arrives at http://www.somedomain.com/yyyy and redirects me to the Wildfly server where an application is responding to the URL : 8080 / app
How could I do it in the most effective way? Using the rewrite module in the .htaccess file or using the Apache proxy module and configuring it in the Apache virtual host? How would I have to do it?
Thank you very much in advance.
You're mixing a few things that are not related to each other. First of all, a redirect is something different than a proxy. Redirecting means asking the client (browser) to look at another URL. A proxy, on the other hand, retrieves the content of the other URL itself and passes it to the client. Using a proxy, the other URL remains invisible to the client.
Second, mod_rewrite is not limited to htaccess configuration. In fact it's better to configure mod_rewrite in the virtual host configuration, just as you suggested with the proxy configuration.
The htaccess is simply for users who are not allowed to mess with the server configuration itself. Configuration in the htaccess can be limited by the admin for security purposes at the cost of slowing down the server.
That said, if you are looking to map your wildfly server paths into your main server's paths, you might want to use something like this inside your main server's virtual host block:
<Location "/yyyy">
ProxyPass "http://wildfly:8080/app"
</Location>
See http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass for detailed explanations.

How to configure Varnish + Nginx reverse proxy on LAMP server

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.

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 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.