自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Nginx反向代理與服務(wù)器的配置緩沖

開發(fā) 前端
隨著時(shí)代的進(jìn)步科技的發(fā)展nginx反向代理也快速的提升與升級(jí),下面我就對(duì)升級(jí)前和升級(jí)后的nginx反向代理,做一下自己的解析。希望能夠?qū)Υ蠹矣袔椭?/div>

Nginx反向代理關(guān)于對(duì)后端服務(wù)器的配置。對(duì)于廣大的網(wǎng)管員來說nginx反向代理是必修的一門課。下面我們就來看看有關(guān)的內(nèi)容。有三個(gè)后端服務(wù),一個(gè)為web內(nèi)容服務(wù),一個(gè)是論壇服務(wù),一個(gè)為文件服務(wù)。

當(dāng)一個(gè)請(qǐng)求來時(shí),nginx代理服務(wù)器其查看url把請(qǐng)求定向到相應(yīng)的服務(wù)器,這個(gè)配置也緩沖文件服務(wù)的內(nèi)容,但是論壇的和數(shù)據(jù)下載的內(nèi)容就不緩存了,這個(gè)配置也使用了壓縮,更好的節(jié)省內(nèi)存

  1. #######################################################  
  2. ### Calomel.org /etc/nginx.conf BEGIN  
  3. #######################################################  
  4. pid /var/run/nginx.pid;  
  5. user nginx nginx;  
  6. worker_processes 10;  
  7. events {  
  8. worker_connections 1024;  
  9. }  
  10. http {  
  11. ## MIME types  
  12. #include /etc/nginx_mime.types;  
  13. default_type application/octet-stream;  
  14. ## Size Limits  
  15. client_body_buffer_size 128K;  
  16. client_header_buffer_size 128K;  
  17. client_max_body_size 1M;  
  18. large_client_header_buffers 1 1k;  
  19. ## Timeouts  
  20. client_body_timeout 60;  
  21. client_header_timeout 60;  
  22. expires 24h;  
  23. keepalive_timeout 60 60;  
  24. send_timeout 60;  
  25. ## General Options  
  26. ignore_invalid_headers on;  
  27. keepalive_requests 100;  
  28. limit_zone gulag $binary_remote_addr 5m;  
  29. recursive_error_pages on;  
  30. sendfile on;  
  31. server_name_in_redirect off;  
  32. server_tokens off;  
  33. ## TCP options  
  34. tcp_nodelay on;  
  35. tcp_nopush on;  
  36. ## Compression  
  37. gzip on;  
  38. gzip_buffers 16 8k;  
  39. gzip_comp_level 6;  
  40. gzip_http_version 1.0;  
  41. gzip_min_length 0;  
  42. gzip_types text/plain text/css image/x-icon application/x-perl 
    application/x-httpd-cgi;  
  43. gzip_vary on;  
  44. ## Log Format  
  45. log_format main '$remote_addr $host $remote_user [$time_local] 
    "$request" '  
  46. '$status $body_bytes_sent "$http_referer" "$http_user_agent" '  
  47. '"$gzip_ratio"';  
  48. ## Proxy options  
  49. proxy_buffering on;  
  50. proxy_cache_min_uses 3;  
  51. proxy_cache_path /usr/local/nginx/proxy_temp/ levels=1:2 
    keys_zone=cache:10m inactive=10m max_size=1000M;  
  52. proxy_cache_valid any 10m;  
  53. proxy_ignore_client_abort off;  
  54. proxy_intercept_errors on;  
  55. proxy_next_upstream error timeout invalid_header;  
  56. proxy_redirect off;  
  57. proxy_set_header X-Forwarded-For $remote_addr;  
  58. proxy_connect_timeout 60;  
  59. proxy_send_timeout 60;  
  60. proxy_read_timeout 60;  
  61. ## Backend servers (web1 is the primary and web2 will 
    come up if web1 is down)  
  62. upstream webbackend {  
  63. server web1.domain.lan weight=10 max_fails=3 fail_timeout=30s;  
  64. server web2.domain.lan weight=1 backup;  
  65. }  
  66. server {  
  67. access_log /var/log/nginx/access.log main;  
  68. error_log /var/log/nginx/error.log;  
  69. index index.html;  
  70. limit_conn gulag 50;  
  71. listen 127.0.0.1:80 default;  
  72. root /usr/local/nginx/html;  
  73. server_name _;  
  74. ## Only requests to our Host are allowed  
  75. if ($host !~ ^(mydomain.com|www.mydomain.com)$ ) {  
  76. return 444;  
  77. }  
  78. ## Only allow these request methods  
  79. if ($request_method !~ ^(GET|HEAD|POST)$ ) {  
  80. return 444;  
  81. }  
  82. ## Only allow these file types to document root  
  83. location / {  
  84. if ($request_uri ~* (^\/|\.html|\.jpg|\.pl|\.png|\.css|\.
    ico|robots\.txt)$ ) {  
  85. break;  
  86. }  
  87. return 444;  
  88. }  
  89. ## PROXY - Forum   
  90. location /forum/ {  
  91. proxy_pass http://forum.domain.lan/forum/;  
  92. }  
  93. ## PROXY - Data  
  94. location /files/ {  
  95. proxy_pass http://data.domain.lan/;  
  96. }  
  97. ## PROXY - Web  
  98. location / {  
  99. proxy_pass http://webbackend;  
  100. proxy_cache cache;  
  101. proxy_cache_valid 200 24h;  
  102. proxy_cache_use_stale error timeout invalid_header updating 
    http_500 http_502 http_503 http_504;  
  103. proxy_ignore_headers Expires Cache-Control;  
  104. }  
  105. ## All other errors get the generic error page  
  106. error_page 400 401 402 403 404 405 406 407 408 409 410 411 
    412 413 414 415 416 417  
  107. 500 501 502 503 504 505 506 507 /error_page.html;  
  108. location /error_page.html {  
  109. internal;  
  110. }  
  111. }  
  112. }  
  113. #  
  114. #######################################################  
  115. ### Calomel.org /etc/nginx.conf END  
  116. #######################################################  

Nginx反向代理的詳細(xì)介紹,希望大家有所收獲。

【編輯推薦】

  1. Nginx+PHP配置相關(guān)進(jìn)程的簡(jiǎn)要介紹
  2. 修改Nginx php.ini文件的經(jīng)典教程
  3. Nginx 啟動(dòng)腳本如何進(jìn)行自動(dòng)化啟動(dòng)
  4. nginx配置進(jìn)行數(shù)據(jù)輸出的兩種方式
  5. Nginx Resin安裝中的相關(guān)技巧和操作流程
責(zé)任編輯:張浩 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-03-30 18:26:07

Nginx Web服務(wù)

2019-04-08 08:39:47

Nginx代理服務(wù)器

2018-11-05 09:34:43

2012-09-18 09:55:28

2019-04-03 11:22:06

NginxApacheweb服務(wù)器

2019-06-27 08:43:26

服務(wù)器Nginx反向代理

2018-10-14 08:39:52

NginxTomcat服務(wù)器

2022-07-01 07:33:24

nginx反向代理測(cè)試

2020-10-22 08:05:46

Nginx

2011-08-31 16:37:51

Nginx

2009-02-28 14:23:02

2014-04-29 14:54:48

Nginx反向代理

2023-10-17 08:36:28

Nginx代理服務(wù)器

2017-12-18 12:04:02

Nginx代理均衡

2012-04-02 14:31:06

nginx代理緩存

2018-04-17 12:10:40

2019-06-19 15:34:39

Nginx反向代理負(fù)載均衡

2021-08-04 07:26:07

IIS服務(wù)器反向代理

2019-10-22 10:20:13

Nginx反向代理服務(wù)器

2015-09-06 09:53:41

DockerWeave
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)