码迷,mamicode.com
首页 > 其他好文 > 详细

一步一步教你nginx.conf配置

时间:2019-07-01 10:49:45      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:zip   页面   document   zip压缩   agent   write   request   add   param   

 

#运行用户,默认即是nginx,可修改
user root;
#nginx进程,一般设置为和cpu核数一样
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#进程pid存放位置
#pid logs/nginx.pid;

#工作模式及连接数上限
events {
worker_connections 1024;#;单个后台worker process进程的最大并发链接数
}


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;
#设定请求缓存
client_max_body_size 100m;
#开启gzip压缩功能
#gzip on;
#反向代理负载均衡设定部分
#upstream表示负载服务器池,定义名字为webservice1的服务器池
upstream webservice1 {
server 172.16.11.131:8080;
server 172.16.11.132:8081;
ip_hash;
}
#基于域名的虚拟主机
server {
#监听端口
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;
location / {
root /usr/zocrm/file; #站点根目录,即网站程序存放目录
index index.html index.htm; #首页排序
rewrite ^/admin/* /index;
proxy_pass http://webservice1;
proxy_redirect off;
add_header X-Frame-Options "SAMEORIGIN";
#proxy_set_header Host $host;
#proxy_set_header Host $host:20206;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /zoStyle {
root /usr/zocrm/file;
}
location /zocrm/img {
root /usr/zocrm/file;
}
location /zocrm/voice {
root /usr/zocrm/file;
}
location /zocrm/excel {
root /usr/zocrm/file;
}
#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;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#符合php扩展名的请求调度到fcgi server
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000; #抛给本机的9000端口
# fastcgi_index index.php; #设定动态首页
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all; #禁止其他ip访问
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

 

一步一步教你nginx.conf配置

标签:zip   页面   document   zip压缩   agent   write   request   add   param   

原文地址:https://www.cnblogs.com/tan-chao/p/11112540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!