#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile 10240;
events {
use epoll;
worker_connections 10240;
}
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;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_static on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_disable "MSIE [1-5]\.";
gzip_comp_level 4;
gzip_types text/plain application/xml application/x-javascript text/css ;
server {
listen 80;
server_name localhost www.15-1688.com 15-1688.com;
root /home/mlzboy/my/idea2/search/;
charset gb2312;
#optimize_server_names off;
server_name_in_redirect off;
access_log logs/access.log main;
location / {
#root html;
#index index.html index.htm;
if ($host != 'www.15-1688.com' ) {
rewrite ^/(.*)$ http://www.15-1688.com/$1 permanent;
}
if (!-e $request_filename) {
#rewrite ^/q/([^/]+)/(\w\d+)and(\w\d+)and(\w\d+)\.html /qq/?q=$1&pos=$2,$3,$4 break;
#rewrite ^/q/([^/]+)/(\w\d+)and(\w\d+)\.html /qq/?q=$1&pos=$2,$3 break;
#rewrite ^/q/([^/]+)/(\w\d+)\.html /qq/?q=$1&pos=$2 break;
#rewrite ^/q/([^/]+)/?$ /qq/?q=$1&pos=p1,z1,s1 break;
rewrite ^/q/(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?pos=$1,$2,$3,$4,$5,$6 break;
rewrite ^/q/(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?pos=$1,$2,$3,$4,$5 break;
rewrite ^/q/(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?pos=$1,$2,$3,$4 break;
rewrite ^/q/(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?pos=$1,$2,$3 break;
rewrite ^/q/(\w.*?)and(\w.*?)\.html /qq/?pos=$1,$2 break;
rewrite ^/q/([^/]+)\.html /qq/?q=$1 break;
rewrite ^/q/([^/]+)/?$ /qq/?q=$1 break;
# rewrite ^/q/([^/]+)/(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?q=$1&pos=$2,$3,$4,$5,$6 break;
# rewrite ^/q/([^/]+)/(\w.*?)and(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?q=$1&pos=$2,$3,$4,$5 break;
# rewrite ^/q/([^/]+)/(\w.*?)and(\w.*?)and(\w.*?)\.html /qq/?q=$1&pos=$2,$3,$4 break;
# rewrite ^/q/([^/]+)/(\w.*?)and(\w.*?)\.html /qq/?q=$1&pos=$2,$3 break;
# rewrite ^/q/([^/]+)/(\w.*?)\.html /qq/?q=$1&pos=$2 break;
# rewrite ^/q/([^/]+)\.html /qq/?q=$1 break;
# rewrite ^/q/([^/]+)/?$ /qq/?q=$1 break;
#rewrite ^/report.html /report break;
#rewrite ^/q/(.*?)/(.*?)$ /qq/?q=$1&pos=$2 break;
#rewrite ^/q/(.*?)$ /qq/?q=$1 last;
#rewrite ^/convert$ /convert last;#不需要,已经默认支持就是不重写
}
#for uwsgi
uwsgi_pass unix:///tmp/uwsgi.sock;
include uwsgi_params;
#return 403
}
location ~* ^/news{
expires 0d;
}
location ~* ^/images/ {
access_log off;
expires 0d;
}
location ~* ^/v_js/ {
access_log off;
expires 0d;
}
location ~* ^/imagesNew/ {
access_log off;
expires 0d;
}
error_page 404 500 502 503 504 /500.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
location = /500.html {
root /home/mlzboy/my/idea2/search/;
}
# 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:9000;
# 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 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
来源:https://www.cnblogs.com/lexus/archive/2010/09/06/1818957.html