nginx配置反向代理服务
2015-07-06 21:34
507 查看
#user nobody; worker_processes 4; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; server_name_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; #keepalive_timeout 0; keepalive_timeout 90; tcp_nodelay on; #fastcgi settings fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; #gzip settings gzip on; gzip_min_length 1k; gzip_buffers 4 16k; #gzip_http_version 1.1 gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml gzip_vary on; #允许客户端请求的最大单个文件字节数 client_max_body_size 50m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为保存到本地再传给用户 client_body_buffer_size 256k; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; proxy_connect_timeout 300s; #nginx跟后端服务器连接超时时间(代理连接超时) proxy_read_timeout 300s; #连接成功后,后端服务器响应时间(代理接收超时) proxy_send_timeout 300s; proxy_buffer_size 64k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置 proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 64k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传递请求,而不缓冲到磁盘 proxy_ignore_client_abort on; #不允许代理端主动关闭连接 server { listen 192.168.88.134:8080; server_name 192.168.88.134; #charset koi8-r; access_log logs/host.access.log main; location / { root html; index index.html index.htm index.php; #autoindex on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } location ~ \.cgi$ { root html; fastcgi_pass 127.0.0.1:7000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # server { listen 192.168.88.135:8080; server_name 192.168.88.135; location / { root html; index index.html index.htm index.php; } location ~ \.cgi$ { root html; fastcgi_pass 127.0.0.1:7000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } } server { listen 192.168.88.136:8080; server_name 192.168.88.136; location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:2000; }
} }
访问路径:http://192.168.88.136:8080/test.cgi
之前需要设置cgi才能访问test.cgi程序,设置代理之后,通过 192.168.88.136:8080这个代理也能正常访问,说明代理功能正常实现文章参考: http://www.cnblogs.com/edisonchou/p/4126742.html http://touzi.github.io/Ubuntu下nginx设置多端口转发(反向代理)/
相关文章推荐
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
- 20150624_OC之代理及反向代理的简单例子
- nginx做反向代理和后端web服务器之间的交互
- squid3.5.5的编译安装
- 反向代理负载均衡
- Nginx反向代理Tomcat
- nginx 反向代理 504 错误
- squid存储机制
- ATS日志格式中的Squid-和Netscape-格式的缓存结果码
- Nginx反向代理和负载均衡部署指南
- 关于负载均衡、集群、正反向代理的理解
- Nginx反向代理前端limit限速模块总结
- Nginx反向代理模板
- ngrok 本地反向代理工具
- 负载均衡
- 配置squid 代理
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
- Nginx反向代理和负载均衡部署指南
- Nginx七层反向代理和负载均衡
- 自动化Nginx服务器的反向代理的配置方法