blueice 发表于 2018-11-9 06:52:33

Centos6.2_x64位系统安装nginx+tomcat

# catnginx6/conf/nginx.conf  
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;
  
worker_rlimit_nofile 51200;
  
events {
  
use epoll;
  
worker_connections 51200;
  
}
  
http {
  
include mime.types;
  
default_type application/octet-stream;
  
# limit_zone one $binary_remote_addr 10m;
  
server_names_hash_bucket_size 256;
  
client_header_buffer_size 256k;
  
large_client_header_buffers 4 256k;
  
client_max_body_size200m;
  
client_body_buffer_size 256k;
  
sendfile on;
  
tcp_nopush on;
  
tcp_nodelay on;
  
send_timeout 3m;
  
keepalive_timeout 120;
  
server_tokens off;
  
gzip on;
  
gzip_min_length 1k;
  
gzip_buffers 4 16k;
  
gzip_http_version 1.0;
  
gzip_comp_level 2;
  
gzip_types text/plain application/x-javascripttext/css application/xml text/jsp;
  
gzip_vary on;
  
#proxy_redirect off;
  
proxy_set_header Host $host;
  
proxy_set_header X-Real-IP $http_x_forwarded_for;
  
proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;
  
proxy_connect_timeout 90;
  
proxy_send_timeout 90;
  
proxy_read_timeout 90;
  
# proxy_buffers 32 4k;
  
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  
'$status $body_bytes_sent "$http_referer" '
  
'"$http_user_agent" "$http_x_forwarded_for"';
  
proxy_temp_path/opt/proxy_temp_path;
  
proxy_cache_path/opt/proxy_cache_path levels=1:2 keys_zone=cache_one:500m inactive=1dmax_size=30g;
  
# access_log logs/access.log main;
  
#sendfile on;
  
#tcp_nopush on;
  
#keepalive_timeout 0;
  
#keepalive_timeout 65;
  
#gzip on;
  
upstream www.beyond.com{
  
server 127.0.0.1:9080;
  
ip_hash;
  
}
  
server {
  
listen 192.168.8.175:80;
  
server_name www.beyomd.com localhost 192.168.8.175;
  
# charset GBK;
  
#charset UTF-8;
  
access_log logs/access_beyond.log main;
  
if ($host ~beyond.com){
  
rewrite ^(.*)http://www.taokey.com$1 permanent;
  
}
  
if ($host ~9h.com){
  
rewrite ^(.*)http://www.beyond.com$1 permanent;
  
}
  
location ^~/zhuanti/ {
  
rewrite/zhuanti/(.*).html /html/zhuanti/$1.jsp;
  
}
  
location ^~/html/article/{
  
rewrite/html/article/(\d+)/(\d+)/(\d+)/(.*)\.html$ /wineCulture/detail-$1$2$3$4.shtml;
  
}
  
location / {
  
proxy_pass http://www.beyond.com;
  
proxy_set_header X-Real-IP $http_x_forwarded_for;
  
index index.html index.shtmlindex.jsp login.jsp index.htm;
  
#proxy_redirect off;
  
}
  
location ~^/static/ {
  
root /opt/newWebshop/;
  
access_log on;
  
expires 12h;
  
}
  
location ~^/re- {
  
proxy_pass http://www.beyond.com;
  
proxy_set_header Host $host;
  
proxy_set_header X-Real-IP $remote_addr;
  
}
  
location ~^/pi- {
  
proxy_pass http://www.beyond.com;
  
proxy_set_header Host $host;
  
proxy_set_header X-Real-IP $remote_addr;
  
}
  
location ~^/wineCulture/?$ {
  
rewrite^/wineCulture/?$ /wineCulture/content_cultureIndex.shtml;
  
}
  
location ~^/wineCulture/zuixinjiushili-(\d+)/?$ {
  
rewrite/wineCulture/zuixinjiushili-(\d+)/? /wineCulture/content_showArticleList.shtml?more=3&page=$1 last;
  
}
  
location ~^/wineCulture/hongjiuyujiankang-(\d+)/?$ {
  
rewrite/wineCulture/hongjiuyujiankang-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=5&seek=last;
  
}
  
location ~^/wineCulture/jiuyoutianxia-(\d+)/?$ {
  
rewrite/wineCulture/jiuyoutianxia-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=6&seek=last;
  
}
  
location~^/wineCulture/hongjiuyishu-(\d+)/?$ {
  
rewrite/wineCulture/hongjiuyishu-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=7&seek=last;
  
}
  
location~^/wineCulture/mingjiazhuanlan-(\d+)/?$ {
  
rewrite/wineCulture/mingjiazhuanlan-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=8&seek=last;
  
}
  
location ~^/wineCulture/hongjiutouzi-(\d+)/?$ {
  
rewrite/wineCulture/hongjiutouzi-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=11&seek=last;
  
}
  
location ~^/wineCulture/hongjiumeishi-(\d+)/?$ {
  
rewrite/wineCulture/hongjiumeishi-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=13&seek=last;
  
}
  
location ~^/wineCulture/hongjiuzhuangyuan-(\d+)/?$ {
  
rewrite/wineCulture/hongjiuzhuangyuan-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=15&seek=last;
  
}
  
location ~^/wineCulture/putaojiurumen-(\d+)/?$ {
  
rewrite/wineCulture/putaojiurumen-(\d+)/? /wineCulture/content_showArticleList.shtml?page=$1&pageSize=9&more=19&seek=last;
  
}
  
location ~^/wineCulture/zuixinjiushili/?$ {
  
rewrite/wineCulture/zuixinjiushili/? /wineCulture/content_showArticleList.shtml?more=3&pageSize=9 last;
  
}
  
location ~^/wineCulture/hongjiuyujiankang/?$ {
  
rewrite/wineCulture/hongjiuyujiankang/? /wineCulture/content_showArticleList.shtml?more=5&pageSize=9 last;
  
}
  
location ~^/wineCulture/jiuyoutianxia/?$ {
  
rewrite/wineCulture/jiuyoutianxia/? /wineCulture/content_showArticleList.shtml?more=6&pageSize=9 last;
  
}
  
location ~^/wineCulture/hongjiuyishu/?$ {
  
rewrite/wineCulture/hongjiuyishu/? /wineCulture/content_showArticleList.shtml?more=7&pageSize=9 last;
  
}
  
location ~^/wineCulture/mingjiazhuanlan/?$ {
  
rewrite/wineCulture/mingjiazhuanlan/?/wineCulture/content_showArticleList.shtml?more=8&pageSize=9 last;
  
}
  
location ~^/wineCulture/hongjiutouzi/?$ {
  
rewrite/wineCulture/hongjiutouzi/? /wineCulture/content_showArticleList.shtml?more=11&pageSize=9 last;
  
}
  
location ~^/wineCulture/hongjiumeishi/?$ {
  
rewrite/wineCulture/hongjiumeishi/?/wineCulture/content_showArticleList.shtml?more=13&pageSize=9 last;
  
}
  
location ~^/wineCulture/hongjiuzhuangyuan/?$ {
  
rewrite/wineCulture/hongjiuzhuangyuan/?/wineCulture/content_showArticleList.shtml?more=15&pageSize=9 last;
  
}
  
location ~^/wineCulture/putaojiurumen/?$ {
  
rewrite/wineCulture/putaojiurumen/?/wineCulture/content_showArticleList.shtml?more=19&pageSize=9 last;
  
}
  
location ^~/html/culture{
  
rewrite /html/culture/cultureIndex\.html /wineCulture permanent;
  
}
  
location ~^/p-list/* {
  
proxy_next_upstream http_502 http_504 error timeout invalid_header;
  
proxy_cache cache_one;
  
proxy_cache_valid 200 304 12h;
  
proxy_cache_key $host$uri$is_args$args;
  
proxy_set_header Host $host;
  
proxy_set_header X-Forwarded-For$remote_addr;
  
proxy_pass http://www.beyond.com;
  
expires 1h;
  
}
  
location ~^/wineCulture/detail-.*\.shtml {
  
proxy_next_upstream http_502http_504 error timeout invalid_header;
  
proxy_cache cache_one;
  
proxy_cache_valid 200 304 12h;
  
proxy_cache_key $host$uri$is_args$args;
  
proxy_set_header Host $host;
  
proxy_set_header X-Forwarded-For $remote_addr;
  
proxy_pass http://www.beyond.com;
  
expires 12h;
  
}
  
location =/wineCulture/content_cultureIndex.shtml {
  
proxy_next_upstream http_502 http_504 error timeout invalid_header;
  
proxy_cache cache_one;
  
proxy_cache_valid 200 304 12h;
  
proxy_cache_key $host$uri$is_args$args;
  
proxy_set_header Host $host;
  
proxy_set_header X-Forwarded-For $remote_addr;
  
proxy_pass http://www.beyond.com;
  
expires 4h;
  
}
  
location =/daogou/daogou_index.shtml {
  
proxy_next_upstream http_502 http_504 error timeout invalid_header;
  
proxy_cache cache_one;
  
proxy_cache_valid 200 304 12h;
  
proxy_cache_key $host$uri$is_args$args;
  
proxy_set_header Host $host;
  
proxy_set_header X-Forwarded-For $remote_addr;
  
proxy_pass http://www.beyond.com;
  
expires 12h;
  
}
  
location ~ .*\.(jsp|do|shtml)?$ {
  
proxy_pass http://www.beyond.com;
  
proxy_set_header X-Real-IP $http_x_forwarded_for;
  
}
  
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  
root /opt/webshop/;
  
access_log off;
  
expires 30d;
  
}
  
location ~ .*\.(js|css|htm|html)?$ {
  
# proxy_pass http://www.beyond.com;
  
# proxy_set_header X-Real-IP $remote_addr;
  
root /opt/webshop/;
  
access_log off;
  
expires 12h;
  
}
  
location /html {
  
root /opt/webshop/;
  
index index.html index.jsp index.shtml login.jspindex.htm;
  
access_log off;
  
expires 12h;
  
}
  
location ^~ /bg
  
{
  
return 404;
  
}
  
location ^~ /WEB-INF
  
{
  
return 404;
  
}
  
error_page 404 http://www.beyond.com/404.jsp;
  
error_page 500 502 503 504 /50x.html;
  
location =/50x.html {
  
root html;
  
}
  
server_name_in_redirect off;
  
}
  
}
  
注意:网站域名我经过的修改。
  
10.挂载旧网站和新网站数据,网站数据是通过NFS实现挂载的


页: [1]
查看完整版本: Centos6.2_x64位系统安装nginx+tomcat