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. server{ 
  28.         listen 80; 
  29.         server_name jpg1.test.com; 
  30.         root /data/webroot/jpg1; 
  31.  
  32.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  33.                 expires 1d; 
  34.                 proxy_store on
  35.                 proxy_store_access user:rw group:r all:r; 
  36.                 proxy_temp_path /data/webroot/jpg1;          
  37. include proxy.conf;
  38.                 if ( !-e $request_filename) { 
  39.                 proxy_pass  http://jpg1;}} 
  40.  
  41. server{ 
  42.         listen 80; 
  43.         server_name jpg2.test.com; 
  44.         root /data/webroot/jpg2; 
  45.  
  46.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  47.                 expires 1d; 
  48.                 proxy_store on
  49.                 proxy_store_access user:rw group:r all:r; 
  50.                 proxy_temp_path /data/webroot/jpg2; 
  51.           include proxy.conf;
  52.                 if ( !-e $request_filename) { 
  53.                 proxy_pass  http://jpg2;}} 
  54.  
  55. server{ 
  56.         listen 80; 
  57.         server_name jpg3.test.com; 
  58.         root /data/webroot/jpg3; 
  59.  
  60.         location ~* .*\.(jpg|gif|js|css|html|htm)$ { 
  61.                 expires 1d; 
  62.                 proxy_store on
  63.                 proxy_store_access user:rw group:r all:r; 
  64.                 proxy_temp_path /data/webroot/jpg3; 
  65.           include proxy.conf;
  66.                 if ( !-e $request_filename) { 
  67.                 proxy_pass  http://jpg3;}} 
  68.  

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

  113. : 
  114. 1、  
  115. apache , nginx  
  116. 2、apache 
  117.  
  118. if ( !-e $request_filename) { 
  119.     proxy_pass  http://172.16.0.110:83;}
  120. /etc/hosts , web 。 !
  121. 4、 proxy_set_header Accept-Encoding ''
  122. nginx   gzip   
  123. proxy_set_header Accept-Encoding 'gzip'
  124. nginx   gzip   
  125. proxy_set_header Accept-Encoding ''
  126. 5、nginx
  127. 6、 proxy_temp_path nginx , nginx nginx
  128. 7、proxy_next_upstream ,nginx ,

좋은 웹페이지 즐겨찾기