nginx简单配置
user nobody;
worker_processes 1;
error_log /usr/local/nginx/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 /usr/local/nginx/logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#开启gzip压缩
gzip on;
#文件最大大小,可用来限制上传文件的大小
client_max_body_size 100m;
#将不带www的域名转到带www的域名
server {
#监听80端口
listen 80;
#域名
server_name ***.com;
rewrite ^/(.*) http://www.***.com/ permanent;
}
server {
listen 80;
server_name www.***.com;
#设置网站根目录
set $htdocs /project/na2;#此处定义了htdocs
root $htdocs;
#设置编码格式
charset utf-8;
#设置网站首页,加快首页加载速度
location =/ {
index index.html index.jsp;
}
#所有请求转到localhost:8088
location / {
index index.jsp;
proxy_pass http://localhost:8088;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#缓存图片30天
location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js|html)$ {
expires 30d;
}
#禁止访问/WEB-INF
location ~^/(WEB-INF)/{
deny all;
}
}
}
页:
[1]