#運行用戶,默認便是nginx,可修改
user root;
#nginx進程,通常設置爲和cpu核數同樣
worker_processes 1;php
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#進程pid存放位置
#pid logs/nginx.pid;html
#工做模式及鏈接數上限
events {
worker_connections 1024;#;單個後臺worker process進程的最大併發連接數
}nginx
http {
include mime.types;#文件擴展名與類型映射表
default_type application/octet-stream;#默認文件類型web
#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;session
#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;
}app
# 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;
# }
#}
}