Enterprise-level application service dynamic and static separation

Only the implementation code is posted here

Enterprise-level application service dynamic and static separation

Background: 7-layer dynamic and static separation is achieved through Nginx, that is, through Nginx reverse proxy configuration rules, dynamic resources, static resources and other services can be parsed by different servers.

Test machine preparation work
7-layer dynamic and static separation case
load balancing lb01

[root@lb01 ~]# cat /application/nginx/conf/proxy.conf 
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
[root@lb01 ~]# cat /application/nginx/conf/nginx.conf
error_log  logs/error.log error;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    upstream static_pools {
            server 10.0.0.7:80 weight=1; #apache
    }
    upstream upload_pools {
            server 10.0.0.7:8080 weight=1; #apache
    }
    upstream default_pools {
            server 10.0.0.8:80 weight=1; #nginx
    }
  server {
        listen       80;
       server_name  blog.51cto.com;
       location / {
            proxy_pass http://default_pools;
            include proxy.conf;
       }
       location /static/ {
            proxy_pass http://static_pools;
            include proxy.conf;
       }
       location /upload/ {
            proxy_pass http://upload_pools;
            include proxy.conf;
       }
  }
}

Web02 Node Configuration

[root@web02 ~]# cat /application/apache/htdocs/blog/static/index.html 
Static
[root@web02 ~]# cat /application/apache/htdocs/blog8080/upload/index.html 
Upload
[root@web02 extra]# pwd
/application/apache/conf/extra
[root@web02 extra]# awk 'NR>16 && NR<24' httpd-vhosts.conf
<VirtualHost *:8080>
    ServerAdmin [email protected]
    DocumentRoot "/application/apache2.2.31/htdocs/blog8080"
    ServerName blog.51cto.com
    ErrorLog "logs/blog8080-error_log"
    CustomLog "logs/blog8080-access_log" common
</VirtualHost>

Enable port listening
vim /application/apache/conf/httpd.conf
Enterprise-level application service dynamic and static separation

Test in browser:
http://blog.51cto.com/static/
http://blog.51cto.com/upload/
http://blog.51cto.com
Enterprise-level application service dynamic and static separation
load balancing 01-log
Enterprise-level application service dynamic and static separation

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325162533&siteId=291194637