nginx+tomcat负载均衡、动静分离群集【☆☆☆☆☆】
以下是一个基于Nginx和Tomcat的简单示例,用于演示如何配置Nginx实现负载均衡和动静分离。
Nginx 配置文件 (nginx.conf)
user 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;
keepalive_timeout 65;
# 用于动静分离的静态文件路径
server {
listen 80;
server_name localhost;
# 静态文件处理
location ~* \.(jpg|jpeg|gif|png|css|js|ico|html)$ {
root /path/to/static/files;
expires 30d;
}
# 代?抱歉,出了点小问题,请稍后重试
评论已关闭