nginx配置
2016-03-14 16:32
507 查看
nginx 配置,包含指定域名跳转、手机访问识别、域名判断代理、日志配置
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /home/logs/nginx/error.log info; pid /run/nginx.pid; events { worker_connections 1024; } http { #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; log_format acc '$time_local|$remote_addr|$remote_user|"$request"|' '$status|$body_bytes_sent|"$http_referer"|' '"$http_user_agent"|"$http_x_forwarded_for"|$request_time|$upstream_response_time|$proxy_add_x_forwarded_for'; access_log /home/logs/nginx/access.log acc; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type text/html; charset UTF-8; gzip on; gzip_disable "msie6"; gzip_proxied any; gzip_min_length 1000; gzip_comp_level 6; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; open_file_cache max=100000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; fastcgi_intercept_errors on; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name www.xxx.com xxx.com; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; if ($host = 'xxx.com' ) { rewrite ^/(.*)$ http://www.xxx.com/$1 permanent; } location /swallow { index index.htm index.html index.jsp; proxy_set_header Host $host:$server_port; # proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:8080; } location /pay { index index.htm index.html index.jsp; proxy_set_header Host $host:$server_port; # proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://10.104.2.22; } location / { #手机访问跳转触屏版 if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC\-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT\-)|(SonyEricsson)|(NEC\-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi\-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG\-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC\-)|(SED\-)|(EMOL\-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" ) { rewrite ^/(.*)$ http://www.xxx.com/swallow/wap permanent; } index index.htm index.html index.jsp; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; client_max_body_size 128m; if ($host = "aaa.xxx.com") { proxy_pass http://10.104.2.22:8245; } if ($host = "bbb.xxx.com") { proxy_pass http://10.104.2.22:8145; } if ($host = "www.xxx.com") { proxy_pass http://10.104.2.22:8045; } error_page 404 = /404.html; error_page 500 502 503 504 = /50x.html; } } }
相关文章推荐
- nginx 反代+负载均衡
- Nginx中文域名配置
- lvs、haproxy、nginx 负载均衡的比较分析
- 欢迎使用CSDN-markdown编辑器
- 为Nginx 创建 Windows 的服务程序
- nginx.conf配置文件详解
- centos 7上nginx+uwsgi 性能调优
- 在windows下将Nginx添加为系统服务
- Nginx服务器出现413 request entity too large nginx的处理方法
- Mac下配置Nginx服务器
- Nginx日志文件切割
- Nginx配置文件nginx.conf中文详解(总结)
- nginx(七)gzip压缩功能
- 编译安装nginx1.9.7+php7.0.0服务器环境
- nginx upstream模块
- nginx 安装(1.9源码)
- 七、Nginx学习笔记七Nginx的Web缓存服务
- 六、Nginx 防盗链
- LNMP搭建,nginx整合php-fpm即fastCGI实现,以及nginx的多虚拟主机配置
- linux 安装 nginx