主配置文件 /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; } }
相关推荐
Nginx配置文件结构 nginx文件结构 Nginx 代理服务的配置说明 Nginx 负载均衡详解 热备 轮询 加权轮询 ip_hash 页面刷新404 nginx 转发 转发到某一个端口 转发到某多个端口 http转换https Nginx配置文件结构 打开conf...
主要介绍了前端必备Nginx配置详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
本节我们来使用nginx来实现负载均衡,当然前提是websocket后台使用的是真正的消息代码来实现,我们在上一章就已经用rabbitmq来实现了stomp消息
Nginx配置文件 nginx.conf 详解doc文档
Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的,Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。这篇文章主要介绍了Nginx配置文件,需要的朋友参考下
#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件, #对于普通应用,必须设为 on, #如果用来进行下载等应用磁盘IO重负载应用,可设置为 off, #以平衡磁盘与网络I/O处理速度,降低...
nginx 配置模板,正常项目中使用的一些配置。 server { listen 80; server_name www.test.com; charset utf-8; access_log logs/access.log; root "E:/front"; proxy_set_header Host $host; set $uid "-"; ...
Vue项目结果build编译后,放在Nginx的html文件夹内,替换该配置文件,就可以在Nginx服务器上运行Vue项目
主要介绍了详解nginx 配置文件解读,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧