主配置文件 /etc/nginx/nginx.conf
这里的问题,配置以后速度非常慢,http和https都慢。
猜测原因:
1.Nginx运行的时候是nginx账号。证书是root用户的,切换chown以后好了。
2.服务器提供商网络问题
server {
listen 80;
listen 443 ssl;
server_name www.*.cn;
#ssl on; //这行必须要注释掉
ssl_certificate /usr/local/nginx/conf/zou_lu.crt;
ssl_certificate_key /usr/local/nginx/conf/zoulukey.pem;
}
user nginx;
worker_processes 1;
error_log /work/nginx/log/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 $request_body "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$http_cookie"';
access_log /work/nginx/log/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
limit_req_zone $cookie_token zone=session_limit:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=auth_limit:3m rate=1r/s;
limit_req_zone $binary_remote_addr zone=dynamic_limit:10m rate=5r/s;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
主配置中include的conf文件
upstream webservice{
server 192.168.232.x:19100;
server 192.168.232.x:19100;
}
upstream ent_webservice{
server 192.168.232.x:19101;
}
upstream patent_webservice{
server 192.168.232.x:19101;
}
server {
listen 80;
server_name [域名];
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /work/nginx/www;
index index.html index.htm;
}
location /auth {
limit_req zone=auth_limit burst=1;
if ($arg_url = "") {
return 403;
}
access_by_lua '
local random = math.random(9999)
local token = ngx.md5("kc" .. ngx.var.remote_addr .. random)
if (ngx.var.cookie_token ~= token) then
ngx.header["Set-Cookie"] = {"token=" .. token, "random=" .. random}
return ngx.redirect(ngx.var.arg_url)
end
';
}
location ^~ /kc_webservice/ {
proxy_pass http://webservice;
}
#websocket
location ^~ /kc_chat/chat/ {
proxy_pass http://192.168.232.x:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location ^~ /SSE_ENT/ {
proxy_pass http://ent_webservice;
}
location ^~ /SSE_Patent/ {
proxy_pass http://patent_webservice;
}
#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 /usr/share/nginx/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
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1: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;
#}
}
#配置子域名转发
server {
listen 80;
server_name [子域名];
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.232.x:8080;
}
}