nginx 역방향 프 록 시 정적 파일


  
  
  
  
  1. : 
  2. nginx        172.16.0.100 
  3. apache1 web     172.16.0.110 
  4. apache2 web     172.16.0.120 
  5.  
  6. : , apache ,nginx , …… 
  7.  
  8. -------------------------------------------- 
  9. nginx : 
  1. vim /usr/local/nginx/conf/proxy.conf
  2. proxy_redirect off;
  3. proxy_set_header Host $host;
  4. proxy_set_header X-Real-IP $remote_addr;
  5. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  6. proxy_ignore_client_abort on;
  7. proxy_connect_timeout 90;
  8. proxy_send_timeout 90; proxy_read_timeout 90;
  9. proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
  10. proxy_set_header Accept-Encoding '';
  11.  
  12. vim /usr/local/nginx/conf/nginx.conf
  13. server{ 
  14.         listen 80; 
  15.     server_name jpg.test.com; 
  16.     root /data/webroot/jpg; 
  17.  
  18.     location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  19.         expires 1d; 
  20.         proxy_store on; 
  21.         proxy_store_access user:rw group:r all:r; 
  22.         proxy_temp_path /data/webroot/jpg; 
  23.         include proxy.conf;
  24. if ( !-e $request_filename) { 
  25.         proxy_pass  http://jpg;}} 
  26. } 
  27.  
  28. server{ 
  29.         listen 80; 
  30.         server_name jpg1.test.com; 
  31.         root /data/webroot/jpg1; 
  32.  
  33.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  34.                 expires 1d; 
  35.                 proxy_store on; 
  36.                 proxy_store_access user:rw group:r all:r; 
  37.                 proxy_temp_path /data/webroot/jpg1;          
  38. include proxy.conf;
  39.                 if ( !-e $request_filename) { 
  40.                 proxy_pass  http://jpg1;}} 
  41. } 
  42.  
  43. server{ 
  44.         listen 80; 
  45.         server_name jpg2.test.com; 
  46.         root /data/webroot/jpg2; 
  47.  
  48.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  49.                 expires 1d; 
  50.                 proxy_store on; 
  51.                 proxy_store_access user:rw group:r all:r; 
  52.                 proxy_temp_path /data/webroot/jpg2; 
  53.           include proxy.conf;
  54.                 if ( !-e $request_filename) { 
  55.                 proxy_pass  http://jpg2;}} 
  56. } 
  57.  
  58. server{ 
  59.         listen 80; 
  60.         server_name jpg3.test.com; 
  61.         root /data/webroot/jpg3; 
  62.  
  63.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  64.                 expires 1d; 
  65.                 proxy_store on; 
  66.                 proxy_store_access user:rw group:r all:r; 
  67.                 proxy_temp_path /data/webroot/jpg3; 
  68.           include proxy.conf;
  69.                 if ( !-e $request_filename) { 
  70.                 proxy_pass  http://jpg3;}} 
  71. } 
  72.  

  73.  
  74.  
  75. upstream jpg { 
  76.      server 172.16.0.110:80 max_fails=3 fail_timeout=30s; 
  77.      server 172.16.0.120:80 max_fails=3 fail_timeout=30s; 
  78. } 
  79. upstream jpg1 { 
  80.      server 172.16.0.110:81 max_fails=3 fail_timeout=30s; 
  81.      server 172.16.0.120:81 max_fails=3 fail_timeout=30s; 
  82. } 
  83. upstream jpg2 { 
  84.      server 172.16.0.110:82 max_fails=3 fail_timeout=30s; 
  85.      server 172.16.0.120:82 max_fails=3 fail_timeout=30s; 
  86. } 
  87. upstream jpg3 { 
  88.      server 172.16.0.110:83 max_fails=3 fail_timeout=30s; 
  89.      server 172.16.0.120:83 max_fails=3 fail_timeout=30s; 
  90. } 
  91.  
  92. --------------------------------------------- 
  93.  
  94. apache : !!! 
  95.  
  96. <VirtualHost *:80> 
  97.     ServerAdmin [email protected] 
  98.     DocumentRoot "/data/webroot/jpg" 
  99.     ServerName jpg.test.com 
  100. </VirtualHost> 
  101.  
  102. <VirtualHost *:81> 
  103.     ServerAdmin [email protected] 
  104.     DocumentRoot "/data/webroot/jpg" 
  105.     ServerName jpg1.test.com 
  106. </VirtualHost> 
  107.  
  108. <VirtualHost *:82> 
  109.     ServerAdmin [email protected] 
  110.     DocumentRoot "/data/webroot/jpg2" 
  111.     ServerName jpg2.test.com 
  112. </VirtualHost> 
  113.  
  114. <VirtualHost *:83> 
  115.     ServerAdmin [email protected] 
  116.     DocumentRoot "/data/webroot/jpg3" 
  117.     ServerName jpg3.test.com 
  118. </VirtualHost> 
  119.  
  120. ------------------------------------------------------------------------------------------- 

  121. : 
  122. 1、  
  123. apache , nginx  
  124. 2、apache 
  125.  
  126. if ( !-e $request_filename) { 
  127.     proxy_pass  http://172.16.0.110:83;}
  128. /etc/hosts , web 。 !
  129. 4、 proxy_set_header Accept-Encoding ''; 
  130. nginx   gzip   
  131. proxy_set_header Accept-Encoding 'gzip'; 
  132. nginx   gzip   
  133. proxy_set_header Accept-Encoding ''; 
  134. 5、nginx
  135. 6、 proxy_temp_path nginx , nginx nginx
  136. 7、proxy_next_upstream ,nginx ,

좋은 웹페이지 즐겨찾기