windown 版 NGINX 作为反向代理与静态分离, 带着两台TOMCAT, 不知道为什么登录系统页面很慢,两个TOMCAT连接是正确的,都可以通过NGINX来访问,同时查过不是数据为的连接的问题,因为只有十来条数据,下面是NGINX的配置,请问位大神帮忙解决或者把NGINX正确的配置方式告诉我,请指出我的错误地方。谢谢
worker_processes 1;
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 65;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
client_body_buffer_size 512k;
client_max_body_size 300m;
large_client_header_buffers 4 32k;
tcp_nodelay on;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 64k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript application/json text/css application/xml;
gzip_vary on;
upstream localhost.com {
ip_hash;
server 127.0.0.1:8080 weight=1;
server 127.0.0.1:8081 weight=1;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
#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;
}
#静态文件放置地方,例如图片,JS
location ^~ /resources/ {
root C:\web\apache-tomcat-1-8.5.11\webapps\HRS\resources;
expires 10d;
}
#EXT JS放置地方
location ^~ /ext/ {
root C:\web\apache-tomcat-1-8.5.11\webapps\HRS\ext;
expires 10d;
}
location / {
proxy_pass http://localhost.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
#proxy_redirect default;
}
在nginx access_log里打印出2个时间,你就基本知道慢在哪里了,然后再进一步排除原因:
$request_time $upstream_response_time
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。