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

Nginx反向代理的安裝和測試的基本流程

開發(fā) 前端
Nginx反向代理有不少問題需要我們解決,其中最重要的就是在安裝和調(diào)試中的問題。下面我們就來詳細的解決這些疑難雜癥。

Nginx反向代理有不少需要我們解決的問題,其中有不少問題是基于安裝上的問題,在安裝完成后的相關(guān)調(diào)試也讓很多人頭疼不已。下面就向大家介紹有關(guān)于安裝和調(diào)試的相關(guān)介紹。

由于服務(wù)器apache抗不住目前的并發(fā).加上前端squid配置后,問題依然無法解決.而頁面程序大部分是動態(tài).無法使用fastcgi來處理.因此想使用Nginx反向代理apache.整個配置安裝過程很簡單.在考慮高并發(fā)的情況下,在安裝前就做了些優(yōu)化.目前配置能抗住3000以上并發(fā).好像不是特別大哦?呵~~ 但足以~~ 只是還有少量499問題..期待有人跟我討論解決.

第1部分:安裝

1 建立用戶及組

  1. /usr/sbin/groupadd www  
  2. /usr/sbin/useradd -g www www 

2 安裝pcre 讓Nginx反向代理支持rewrite 方便以后所需 

  1. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.8.tar.gz  
  2. tar zxvf pcre-7.8.tar.gz  
  3. cd pcre-7.8/  
  4. ./configure  
  5. make && make install 

3 安裝Nginx反向代理

  1. wget http://sysoev.ru/nginx/nginx-0.7.58.tar.gz  
  2. tar zxvf nginx-0.7.58.tar.gz  
  3. cd nginx-0.7.58/  
  4. ./configure --user=www --group=www --prefix=/usr/
    local/webserver/nginx --with-http_stub_status_module 
    --with-http_ssl_module 
    --with-cc-opt='-O2' --with-cpu-opt
    =opteron 
  5. make && make install 

注意上文中的--with-cc-opt='-O2' --with-cpu-opt=opteron 這是編譯器優(yōu)化,目前最常用的是-02 而不是3.后面對應(yīng)CPU的型號。

第2部分:配置及優(yōu)化配置文件

1 Nginx.conf 配置文件:

  1. user www www;  
  2. worker_processes 4;  
  3. # [ debug | info | notice | warn | error | crit ]  
  4. error_log /usr/local/webserver/nginx/logs/nginx_error.log crit;  
  5. pid /usr/local/webserver/nginx/nginx.pid;  
  6. #Specifies the value for maximum file descriptors that 
    can be opened by this process.  
  7. worker_rlimit_nofile 51200;  
  8. events  
  9. {  
  10. use epoll;  
  11. worker_connections 51200;  
  12. }  
  13. http  
  14. {  
  15. include mime.types;  
  16. default_type application/octet-stream;  
  17. source_charset GB2312;  
  18. server_names_hash_bucket_size 256;  
  19. client_header_buffer_size 256k;  
  20. large_client_header_buffers 4 256k;  
  21. #size limits  
  22. client_max_body_size 50m;  
  23. client_body_buffer_size 256k;  
  24. client_header_timeout 3m;  
  25. client_body_timeout 3m;  
  26. send_timeout 3m;  
  27. #參數(shù)都有所調(diào)整.目的是解決代理過程中出現(xiàn)的一些502 499錯誤   
  28. sendfile on;  
  29. tcp_nopush on;  
  30. keepalive_timeout 120; #參數(shù)加大,以解決做代理時502錯誤  
  31. tcp_nodelay on;  
  32. include vhosts/upstream.conf;  
  33. include vhosts/bbs.linuxtone.conf;   

2 upstream.conf 配置文件(這也是做負載的配置方法

  1. upstream.conf  
  2. upstream bbs.linuxtone.com {  
  3. server 192.168.1.4:8099;  

3 站點配置文件

  1. bbs.linuxtone.conf  
  2. server  
  3. {  
  4. listen 80;  
  5. server_name bbs.linuxtone.conf;  
  6. charset GB2312;  
  7. index index.html index.htm;  
  8. root /date/wwwroot/linuxtone/;  
  9. location ~ ^/NginxStatus/ {  
  10. stub_status on;  
  11. access_log off;  
  12. }  
  13. location / {  
  14. root /date/wwwroot/linuxtone/;  
  15. proxy_redirect off ;  
  16. proxy_set_header Host $host;  
  17. proxy_set_header X-Real-IP $remote_addr;  
  18. proxy_set_header REMOTE-HOST $remote_addr;  
  19. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  20. client_max_body_size 50m;  
  21. client_body_buffer_size 256k;  
  22. proxy_connect_timeout 30;  
  23. proxy_send_timeout 30;  
  24. proxy_read_timeout 60;  
  25. proxy_buffer_size 256k;  
  26. proxy_buffers 4 256k;  
  27. proxy_busy_buffers_size 256k;  
  28. proxy_temp_file_write_size 256k;  
  29. proxy_next_upstream error timeout invalid_header http_500 
    http_503 http_404;  
  30. proxy_max_temp_file_size 128m;  
  31. proxy_pass http://bbs.linuxtone.com;  

參數(shù)都有所調(diào)整.目的是解決代理過程中出現(xiàn)的一些502 499錯誤 

  1. #Add expires header for static content  
  2. location ~* \.(jpg|jpeg|gif|png|swf)$ {  
  3. if (-f $request_filename) {  
  4. root /date/wwwroot/linuxtone/;  
  5. expires 1d;  
  6. break;  
  7. }  
  8. }  
  9. log_format access '$remote_addr - $remote_user [$time_local] "$request" '  
  10. '$status $body_bytes_sent "$http_referer" '  
  11. '"$http_user_agent" $http_x_forwarded_for';  
  12. access_log /exp/nginxlogs/bbs.linuxtone_access.log access;  

以上就是對Nginx反向代理的詳細介紹,希望大家有所收獲。

【編輯推薦】

  1. nginx配置相關(guān)結(jié)構(gòu)劃分的技巧
  2. nginx配置文件基本應(yīng)用參考手冊
  3. nginx優(yōu)化設(shè)置基本的TCP配置
  4. nginx配置文件優(yōu)化中的比較
  5. nginx設(shè)置404相關(guān)問題代碼答疑
責任編輯:張浩 來源: 博客園
相關(guān)推薦

2018-11-12 12:17:00

2024-07-22 15:34:25

2019-07-09 15:10:02

Nginx反向代理負載均衡

2022-07-01 07:33:24

nginx反向代理測試

2017-12-18 12:04:02

Nginx代理均衡

2023-12-05 09:14:54

2012-12-07 10:14:48

Nginx負載均衡

2020-10-22 08:05:46

Nginx

2015-06-05 11:26:58

nginx運維

2010-03-29 17:56:20

Nginx反向代理

2023-10-17 08:36:28

Nginx代理服務(wù)器

2016-01-08 10:37:56

FreeBSD 10.Nginx反向代理

2010-06-12 18:00:16

ARP協(xié)議

2023-09-08 00:07:41

2019-06-19 15:34:39

Nginx反向代理負載均衡

2014-04-29 14:54:48

Nginx反向代理

2010-03-30 18:26:07

Nginx Web服務(wù)

2023-09-13 07:16:31

Ngnix代理服務(wù)器

2020-08-06 08:23:24

Nginx反向代理Web安全

2017-09-06 10:14:29

Nginx TCPmail郵件
點贊
收藏

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