nginx.conf
#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; 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; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream tomcats { server 10.154.49.196:8080; } upstream tomcats-quartz { server 10.154.49.196:8081; } server { listen 80; server_name www.itzixi.com; #itzixi.com; access_log /home/wwwlogs/www.itzixi.com_nginx.log combined; root /home/wwwroot/www.itzixi.com; index index.html index.htm index.jsp index.action index; #rewrite ^(.*)$ https://$host$1 permanent; location ~ .*.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*.(js|css)?$ { expires 7d; access_log off; } location ~ { #/ { proxy_pass http://tomcats; # open tomcat servera include proxy.conf; } } # ssl(https) config # server { # listen 443; # server_name www.itzixi.com; # itzixi.com; # access_log /home/wwwlogs/www.itzixi.com_nginx.log combined; # root /home/wwwroot/www.itzixi.com; # index index.html index.htm index.jsp index.action index; # # location ~ .*.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { # expires 30d; # access_log off; # } # # location ~ .*.(js|css)?$ { # expires 7d; # access_log off; # } # # ssl on; # ssl_certificate 1_www.itzixi.com_bundle.crt; # ssl_certificate_key 2_www.itzixi.com.key; # ssl_session_timeout 5m; # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; # ssl_prefer_server_ciphers on; # location ~ { #/ { # proxy_pass http://tomcats; # open tomcat server # include proxy.conf; # } # # } # image server server { listen 88; server_name localhost; #server_name www.itzixi.com itzixi.com; location /group1/M00 { ngx_fastdfs_module; } } }
proxy.conf
proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 32k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
server.xml,注释掉原来的host,加入下面这行
<Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/home/wwwroot/www.itzixi.com" reloadable="false" crossContext="true"/> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="www.itzixi.com_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
项目从war包解压后放入此目录:
/home/wwwroot/www.itzixi.com