Configure Nginx frontend + Apache backend server environment
illustrate:
Nginx is good at processing static content. Although apache takes up a little more memory and has slightly lower performance, it has always been relatively stable. However, nginx's FastCGI sometimes has a 502 Bad Gateway error. An optional method is to use nginx as a front-end proxy, process static content, and forward all dynamic requests to the back-end apache.
This article is to implement Nginx as the front end and apache as the back end. When the user accesses nginx on port 80, nginx keeps the static content to itself, and forwards the rest to apache on non-80 ports, and apache returns it to nginx after processing.
nginx static resource separation deployment
https://www.cnblogs.com/panxuejun/p/6027730.html
https://segmentfault.com/a/1190000010487262
server { listen 80; server_name 123.57.162.75; charset utf-8; index index.html index.htm index.jsp index.do; root /opt/nginx-1.4.7/html/resources; #Configure Nginx dynamic and static separation, and the defined static pages are directly read from the Nginx release directory. location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root /opt/nginx-1.4.7/html/resources; #expires defines the user's browser cache time as 7 days. If the static page is not updated frequently, it can be set longer, which can save bandwidth and relieve the pressure on the server expires 7d; } } server { server_name static.naice.me; // your domain name or ip root /www/static-web/static-web; // your cloned project path index index.html; // display the home page location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt){ root /www/static-web/static-web; index index.html index.htm; } // static file access }
nginx-based static web page deployment
server { listen 8081; # listen to port 8081 on all ips of this machine server_name _; # Domain name: www.example.com where "_" means get all matching root /home/filename/; # site root directory location / { # There can be multiple locations for configuring routing addresses try_files index.html =404; } }
。。。