nginx 常用配置

  • Post author:
  • Post category:其他



user  nginx;

worker_processes  1;

error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;

events {

worker_connections  1024;

}

http {

include       /etc/nginx/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  /var/log/nginx/access.log  main;

sendfile        on;

#tcp_nopush     on;

keepalive_timeout  65;

client_max_body_size 500m;

/*开启压缩*/

gzip  on;

gzip_disable “MSIE [1-6].”;

gzip_types text/plain application/x-javascript text/css text/javascript;

include /etc/nginx/conf.d/*.conf;

/* 本地APP server */

upstream tomcat{

server 127.0.0.1:8080;

}

server {

listen 80;

server_name  自己的IP或者域名;

charset UTF-8;

access_log on;

location / {

proxy_pass tomcat;/* 本地APP server */

proxy_http_version 1.1;

include proxy.conf;

}

//配置虚拟映射

location /data/{

alias /data;

}

}

}



版权声明:本文为evan_yyz原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。