Articles of nginx

Nginx背后的Gunicorn – 负载testing期间有大量的TIME_WAIT

nginx版本:nginx / 1.9.3 gunicorn(版本19.7.1) 我有一个小型烧瓶API通过nginx后面的gunicorn运行。 当我通过gunicorn直接加载testing时,一切工作正常,但是一旦我将它指向nginx,我就会在nginx服务器上获得非常多的TIME_WAIT套接字。 Gunicorn框是好的。 这里是configuration: Gunicorn: bind = '0.0.0.0:7030' workers = 10 threads = 1 daemon = True DEBUG = "True" Nginx:相关的块: upstream api { keepalive 32; server box1:7030; server box2:7030; } server { listen 7077; server_name localhost; 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_set_header X-Forwarded-Host $server_name; sendfile on; […]

设置nginx反向代理与重写适用于网站中的所有链接

我有以下的Nginxconfiguration: server { listen 80; location /test { rewrite /test(.*) /$1 break; proxy_pass "http://www.example.com/"; } } 这适用于主页,当input“ http:// localhost / test ”时,我得到http://www.example.com/的内容,URL仍然是“ http:// localhost / test ”。 很酷,但是当我点击网站中的一个链接时,说/more_examples我想链接被改写为: http:// localhost / test / more_examples 。 在实践中,我得到以下: http:// localhost / more_examples ,这显然不会工作。 这甚至有可能吗? 任何帮助将不胜感激。

Nginx代理Wix站点只显示浏览器中的空白页面或未find

我们试图通过Nginx代理来代理Wix站点( https://mgertner.wixsite.com/corkscrew-copy )。 我们已经尝试了大部分头文件和Cookie设置,但是我们仍然有空白页面或wix错误。 我们也尝试了SSL代理,但没有任何效果。 getcorkscrew.com返回Wix未find的页面,www.getcorkscrew.com仅为空白页面。 这里是nginxconfiguration(注意,在getcorkscrew.com案例中,我们使用的是上游案例,而不是在wwww.getcorkscrew.com案例中)。 upstream wix { keepalive 100; server mgertner.wixsite.com:443; } server { listen 80; server_name getcorkscrew.com; location / { proxy_http_version 1.1; proxy_pass https://wix/corkscrew-copy; proxy_pass_request_headers on; } } server { listen 80; server_name www.getcorkscrew.com; location / { proxy_http_version 1.1; proxy_pass https://mgertner.wixsite.com/corkscrew-copy; proxy_pass_request_headers on; } } Wix网站设置为在www.getcorkscrew.com上回答。 (所以也许Wix内部路由有问题)。 所有的头文件和cookies都应该被传递。 我们甚至用phpinfo()函数启动了一个PHP服务器,来检查nginx究竟发生了什么变化,唯一不同的是IP地址(显然)和HTTP版本(之后我们已经改变了configuration)。 谢谢,Jan

在Apache或Nginx上限制每个请求的下载和上传速度

我目前正在运行几个Web服务器(一个是基于Apache 2.4,另一个是运行nginx 1.8)。 我需要为每个单独的GET / POST请求设置速率限制,以限制下载和上传速度。 我已经search了,但我发现每个解决scheme似乎只关注下载速度,我也找不到一种方法来设置限制也从客户端发送到请求体内的服务器的数据。 我需要这个,因为大多数请求都与file upload有关。 任何build议将不胜感激。 谢谢!

NGINX Websocket初始通信延迟

我创build了一个Django服务器,它使用Django通道进行websocket通信。 当我用NGINX运行服务器时,服务器和客户端之间的websocket通信有一个初始延迟。 在最初的延迟之后,所有丢失的数据在非常短的时间内到达,然后开始实时通信。 我已经testing了服务器的独立和没有NGINX代理只有一个达芙妮实例,并没有最初的通信延迟。 以下是我的NGINXconfiguration。 如果任何人有任何想法,为什么我会得到一个最初的10秒延迟websocket通信,将不胜感激。 worker_processes 1; events { worker_connections 1024; } http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } 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 0; […]

nginx limit_req_zone以低于指定的速率进行限制

我的configuration中的limit_req_zoneconfiguration如下: limit_req_zone $nginx_version zone=site1:10m rate=1000r/s; 我不希望从区域sit​​e1每秒钟超过1000个请求。 我在我的位置使用这个区域如下: location /exchange/site1/ { limit_req zone=site1 nodelay; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE_ADDR $remote_addr; proxy_set_header Host $http_host; proxy_set_header Content-Type application/json; proxy_pass http://lb-server/site1/; proxy_redirect off; } 但是,当我实际使用ngxtop来查看有多less个请求正在传递时,我发现site1实际上每秒发送大约600个请求,但其中大约一半的请求在nginx中丢失。 我的configuration有问题吗? 我应该增加内存空间吗? 我尝试了100米,但仍然看到相同的行为。 还有什么我在这里失踪,可以帮助吗?

单页应用程序访问API以避免跨域CORS的最佳实践

这里是设置: 在example.com上有一个onPage应用程序,它应该通过AJAX访问域api.example.com上的API。 由于CORS限制,我无法直接使用Ajax访问API,该解决scheme的最佳实践是什么? 我的第一个想法: example.com上的反向代理设置,将所有example.com/api/(.*)请求重新路由到api.example.com/$1 有没有人有更好的主意和/或nginx的例子来解决这个问题?

nginx – 有史以来最为棘手的问题 – 收到的一些请求格式不正确

这个问题对我来说是一个谜,我将非常乐意find解决scheme。 我将提供我认为相关的环境的详细信息,但是如果需要其他任何内容,请发表评论,我将添加。 基础设施: 主机 – 数字海洋液滴 os – Ubuntu 17.04 反向代理 – nginx 1.12.0 (也发生在nginx 1.10.0的问题) 应用服务器 – node-js 7.10.0 (也发生在7.9.0) 客户端 – Android (使用OkHttp 3.8.0发生在几个版本,包括5.0,6.0.1,7.1.1,所以很可能不相关) 所以nginx将stream量转发到nodejs,nodejs处理来自Android客户端的请求。 问题: 对于某些客户端来说,偶尔,对于特定的查询,nodejs收到的json格式不正确。 具体来说,几个字节写在身体的json的开始, 这里是一个例子: 2017-05-24 15:42:14.899 (+0300) – error: Error summary: name: SyntaxError status: 400 request: POST /api/v1/user_details body: J ount_id":"217627","user":{"email": "[email protected]" ….<rest of json is ok> 注意身体的开始 […]

通过cloudflare在nginxnetworking服务器上获取ERR_SSL_VERSION_OR_CIPHER_MISMATCH

我有一个docker工人基础设施组成 1个nginx反向代理1个nginx web服务器1个php7.0 fpm服务器 nginx反向代理和web服务器都使用相同的docker镜像,但只是加载了不同的站点confs。 在反向代理服务器上,它也提供了一个静态的JavaScript SPA,以及反向代理服务器的web服务器。 所以两个nginx容器都运行相同的/etc/nginx/nginx.conf 我的SSLconfiguration在这里 ## # SSL Settings ## ssl_stapling off; ssl_session_timeout 1h; ssl_session_tickets off; ssl_stapling_verify off; ssl_ecdh_curve secp384r1; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS; ssl_certificate /srv/ssl/nginx-selfsigned.crt; ssl_certificate_key /srv/ssl/nginx-selfsigned.key; ssl_dhparam /srv/ssl/dhparam.pem; 我的站点configuration为反向代理是这样的 server { listen 1025 ssl http2; listen [::]:1025 ssl http2; server_name api.site.com; location / […]

nginx具体url来清除

我正在寻找一种方法来清除nginxcaching使用通过在url上添加一个特定的注释。 比方说,我有这个url(项目)与nginxcaching: http://mywebsite/render/render5.php?frame=1&image=nature-1920.jpg 如果我想清除它,我将不得不补充: http://mywebsite/render/render5.php?frame=1&image=nature-1920.jpg&purge=1 如果我们在这个URL的末尾添加&purge=1 ,那么可以清除一个URL吗? 我find的所有教程都使用curl -X命令来清除特定的项目,例如: curl -X PURGE http://mywebsite/render/render5.php?frame=1&image=nature-1920.jpg https://scene-si.org/2016/11/02/purging-cached-items-from-nginx-with-lua/ 而且我希望能够清除一个nginxcaching项(url)而不必使用curl -X命令。