Articles of nginx

SMTP负载平衡与远程主机的IP传递到SMTP服务器?

我正在尝试构build一个负载平衡的SMTP群集。 邮件服务器已经存在并运行Exim 4.最初,我考虑使用Nginx来进行负载均衡,但是在testing系统上,所有的邮件服务器都会将来自负载均衡器IP的入站连接看作是来自负载平衡器IP而不是实际的远程发件人知识产权,广泛谷歌search之后似乎没有任何方法。 因为这有效地将邮件集群变成一个开放的中继,这显然是一个非首创,这是一个可惜的Nginx的工作很好,否则。 所以我正在寻找使用HAProxy,因为我从更进一步的Googlesearch中得知它能够将原始源IP的连接完好无缺地传递,因此系统中继允许列表和ACL将正确运行。 但是,根据几个在线示例设置HAProxy,我得到“SMTP同步错误”(和一个500系列错误,所以邮件将反弹),连接立即下降,或只是连接下降,没有SMTP信息。 这里是使用的haproxy.conf: global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user nobody group nobody daemon stats socket /var/lib/haproxy/stats defaults log global option redispatch retries 3 timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout check 10s maxconn 3000 listen smtp bind 0.0.0.0:25 mode tcp […]

绑定通配符条目,捕获所有未定义(NXDOMAIN)域,而不是仅从本地区域,但仅限于curl,wget,chrome等

我的设置将本地networking上的未定义主机redirect到自定义404页面; 所以对于invalidhostname.subdomain.example.com , bind9服务器将redirect到nginxProxy.subdomain.example.com 。 (本身redirect到另一台服务器上托pipe的404页面) 它符合本地未定义主机名称的预期 。 但是,当涉及到askljdaksjdad.com , nslookup , host , dig所有正确的返回NXDOMAIN ,但google-chrome , curl和wget都从我的子域提供自定义404页面。 它发生在networking上的多台Linux机器上。 configuration文件的相关部分是: 在绑定服务器上: /etc/bind/zones/forward.subdomain.example.com subdomain.example.com IN SOA bind01.subdomain.example.com. nitin.subdomain.example.com ( 64 ; serial 604800 ; refresh (1 week) 86400 ; retry (1 day) 2419200 ; expire (4 weeks) 604800 ; minimum (1 week) ) NS ns02.subdomain.example.com. NS […]

由于PHP-FPM侦听队列,站点变得不可访问,CPU触及100%

我一直在绞尽脑汁,试图解决这个问题,我的生产服务器上每隔几小时随机出现一个Wordpress博客(体面stream量:2000个用户实时平均日,5000+个好日子,每分钟浏览量从300到700+)。 我使用Newrelic监视性能,我注意到一个奇怪的事情: 每几个小时(随机),PHP-FPM池的状态如下(昨天的实际状态) pool: www process manager: static start time: 02/Jan/2017:05:03:16 -0500 start since: 27290 accepted conn: 1107594 listen queue: 777 max listen queue: 794 listen queue len: 40000 idle processes: 0 active processes: 100 total processes: 100 max active processes: 101 max children reached: 0 slow requests: 0 重新启动PHP-FPM和nginx解决了这个问题,但是在几个小时后又发生了。 任何帮助表示赞赏。 请指导我 服务器设置: DigitalOcean 48GB […]

Nginx的API代理表单数据和自定义头没有传递给远程API

我想为此设置一个Nginx。 上下文 从根url服务Angular 2 dist静态文件: http : //example.com – >在/home/www/index.html显示index.html 在我的Angular2项目中,我使用GET,POST在/api/some-endpoints进行一些本地调用。 我希望将/api/{ANY-PATH}调用redirect到一个远程私有URL。 我需要使用我的自定义标题 (例如form-data或apikey标题)进行调用,并将另一个apikey添加到远程服务器的请求中 。 我的问题 使用表单数据值(包含上传的文件)和我的自定义标题: apikey , 253018b8425f4eb08291a1b68c4bc328进行POST调用(从安装了nginx的机器)到/api/document apikey , 253018b8425f4eb08291a1b68c4bc328 远程服务器似乎并没有收到,也没有forms数据,也没有apikey。 我的configuration upstream api-server { server myprivate-api-server.com:8000; } map $http_apikey $api_route { default "error"; 253018b8425f4eb08291a1b68c4bc328 'api-server'; } server { listen 80; index index.html; server_name example.com; location = /501_apikey.html { root /home/www/error_pages; internal; […]

nginx代理 – aws emr集群

说明:启动EMR集群时,每个应用程序都configuration为公开其UI。 目标:使用不带端口号的友好URL通过Nginx访问UI 细节: 每个用户界面都在不同的端口上 基本authentication(htpass) 有些用户界面会将您redirect到EMR主机的private-dns-record(可以手动修复它们,需要Nginx来做) UI端口:8088,8890,8888,18080,50070 已经做了什么? A)按照这篇文章,我们可以访问Zeppelin B)我们试图修改这个configuration以允许更多的位置这背后的逻辑就是通过这样做,我们可以用'/ somename'来访问nginx,并且使用'upstream'redirect到EMR master的相关端口,但是很遗憾不行。 location /hadoop { proxy_pass hxxp://hadoop } C)我们尝试了重写规则,但一旦我们把 rewrite ^/hadoop(.*)$ /$1 permenant; 在/somename它实际上是: location / 问题:我们如何使用简单友好的URL(例如hxxp:// mynginx / hadoop)来访问UI? 例如: http://nginx/app应该redirect到http://upstream-server:8088

在Linux服务器上的子文件夹中安装了NGINX + Drupal

我试图像这样configuration服务器有这个可访问的地址: domain.com/webmail (webmail app) domain.com/app (node.js app) domain.com/mailadmin (mail administration app) domain.com/site (drupal website) 我的根目录是/var/www 其中有以下目录: /var/www/webmail /var/www/app /var/www/postfixadmin /var/www/site 我已经尝试过几种configuration,没有一个能够工作(有些工作部分,显示主页或显示所有页面,但没有任何CSS样式) 干杯

在上游读取时中间“上游过早closures连接”

我在服务器上收到一个中间的“上游过早closures连接,而上游读取”错误。 错误只发生在从Amazon S3向服务器请求的数据上,而不在服务器自身的任何文件上。 我的设置如下: 1基于Nginx nginx版本的负载均衡器:nginx / 1.11.5(离开Ubuntu库) 它的configuration是: server { server_name example.com client_body_timeout 12s; client_header_timeout 12s; keepalive_timeout 15s; access_log off; proxy_connect_timeout 1000s; proxy_send_timeout 1000s; proxy_read_timeout 1000s; send_timeout 1000s; location / { set $ua $http_user_agent; if ($http_user_agent = "") { set $ua "Fixing-Empty-User-Agent"; } proxy_pass http://front_least; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect […]

Ubuntu16.04:Nginx 1.10:Nginx提供多个证书信息。 SSL在浏览器上完美工作,但面临curl的问题。 cURL错误51

我有一个Ubuntu的服务器(16.04)nginx / 1.10.0 + letsencrypt多个网站。 SSL在浏览器中看起来工作正常和完美。 但是我们的开发者应用程序正在使用一个curl请求(使用SSL)并且面临错误 Update Failed: Download failed. cURL error 51: SSL: certificate subject name 'domain2.com' does not match target host name 'domain1.com' 在使用SSLLABS进行检查时,它显示了A_grade,但它正在加载多个证书(同一服务器中的另一个域的证书) Certificate #1: RSA 2048 bits (SHA256withRSA) 和 Certificate #2: RSA 2048 bits (SHA256withRSA) No SNI 并在第二个证书下,有以下错误。 Common names domain2.com MISMATCH Trusted No NOT TRUSTED 卷毛错误也在说第二个域名。 cURL error 51: […]

如何使用标题nginxlogging完整的客户端请求?

我正在寻找logging客户端的请求variables和在HTTP POST中发送的头。 对于nginx.conf文件,示例configuration将如何?

如何在redirect其他stream量时对特定url的http健康检查作出响应?

背景:我正在尝试在Google云平台上build立一个实例组。 实例组由许多nginx实例组成,其工作只是将传入的httpsstream量redirect到外部站点。 如果传入的stream量是http,它将被转换为https。 要使实例组工作,它必须响应健康检查请求(使用http或https协议)并返回200。 我遇到的问题是如何定义这样一个nginxconfiguration。 这是我第一次剪掉 它只处理redirect server { listen 80; listen 443 ssl; ssl on; ssl_certificate /etc/nginx/ssl/examples.pem; ssl_certificate_key /etc/nginx/ssl/examples.key; server_name incoming.examples.com; return 301 https://target.examples.com$request_uri; } 我使用http协议将健康检查url设置为“/ _check”。 这是我第一次尝试: server { listen 80; location /_check { return 200 'no content'; } listen 443 ssl; ssl on; ssl_certificate /etc/nginx/ssl/examples.pem; ssl_certificate_key /etc/nginx/ssl/examples.key; server_name incoming.examples.com; return 301 https://target.examples.com$request_uri; […]