Articles of nginx

nginx-rtmp模块:redirect到一个不同的服务器

我对此并不太乐观,但我希望能够获得更多的见解:我的问题是,如果可以将客户端redirect到不同的服务器。 我想到的用例是: 客户端stream式传输到负载均衡器的URL 负载均衡器select一些nginx服务器A通过循环(或随机,无所谓) nginx服务器A有find整个集群上的信息的方法(查看Erlang的BEAM或类似的东西),并确定它是太加载,但nginx服务器B是最less加载,所以它发送一个redirect通知回到客户端 客户端收到30X,但最重要的是,他们的stream,而不是发布到服务器B. 假设我们对客户没有太多的控制权……它可能是使用OBS或其他软件的人。 是否可以使用nginx rtmp模块(或其他模块,如果需要的话)来实现?

重写nginx路由为小写

我想实现的是将所有nginx路由redirect到小写,如/PATH到/path 。 我已经看到你可以通过使用perl模块或lua模块来做到这一点,但有没有办法做到这一点,并使用核心模块或一些内置的function? 谢谢 更新: nginx -V输出: # nginx -V nginx version: nginx/1.10.3 (Ubuntu) built with OpenSSL 1.0.2g 1 Mar 2016 TLS SNI support enabled configure arguments: –with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' –with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' –prefix=/usr/share/nginx –conf-path=/etc/nginx/nginx.conf –http-log-path=/var/log/nginx/access.log –error-log-path=/var/log/nginx/error.log –lock-path=/var/lock/nginx.lock –pid-path=/run/nginx.pid –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-proxy-temp-path=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –with-debug –with-pcre-jit –with-ipv6 –with-http_ssl_module […]

使用Nginx作为具有虚拟主机的Apache服务器的负载平衡器

下面的附加图像代表了我正在构build的应用程序堆栈。 Apache节点是彼此完全相同的副本,并且每个节点都服务于相同的虚拟主机,比如example1.com,example2.com和example3.com。 此外,对于具有数据库后端的Apache节点服务的虚拟主机,数据库将托pipe在Galera集群节点上。 所有这些节点都运行Ubuntu 16.06。 到目前为止,我已经能够成功configuration这个设置的大部分,除了我似乎无法通过Nginx Web负载均衡器传递主机名。 例如,当我去example1.com(并不断刷新),我可以看到,应用程序交付正确地从每个Apache节点交替。 但是当我去example2.com时,仍然显示example1.com。 这不是我的本地/etc/hosts文件的问题。 我相信这是因为我没有正确configurationNginx负载均衡器来传递主机名,以便Apache节点解释它。 这里是我的3个nginx服务器块链接在sites-enabled #/etc/nginx/sites-enabled/example1.dev upstream example1 { least_conn; server do.webserver1:80; server do.webserver2:80; } server { listen 80; server_name example1.dev; location / { proxy_pass http://example1; } } #/etc/nginx/sites-enabled/example2.dev upstream example2 { least_conn; server do.webserver1:80; server do.webserver2:80; } server { listen 80; server_name example2.dev; location / { proxy_pass […]

Https连接有时在Nginx / CentOS上非常慢

OS CentOS 6.4 Nginx:1.12 我有以下奇怪的行为 有时第一个https连接速度非常慢 一旦第一次连接成功,一切都是快速的 服务器负载很低 如果https访问速度很慢,SSHlogin到该服务器的速度也很慢 关联configuration listen 443 ssl; ssl_session_cache shared:SSL:30m; ssl_certificate /opt/cert/xxx.crt; ssl_certificate_key /opt/cert/xxx.key; ssl_session_timeout 30m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; strace日志https://gist.github.com/jilen/d3e8f1686ecc295dddb3390d6548ad01

如果我有弹性负载平衡,我们需要在tomcat之前使用nginx吗?

我目前的configuration设置如下, AWS ELB(https / 443 to 80) –> Webserver_UI ( nginx 80 ) -> nodejs AWS ELB2(https / 8080 to 8080) –> Webserver (nginx 8080) -> localhost tomcat 8081 -> Java code 现在我的问题是我真的需要Nginx的我的第二个Web服务器? 由于tomcat可以直接接受AWS ELB的请求,证书由ELB本身处理。 但是每个人都保留Nginx,那么这个设置的真正优势是什么呢? 我知道我可以尝试“AWS Elastic Beanstalk”而不是nginx,但是在成本方面,我不想尝试它。

Nginx:上游“主机未find”错误的特殊行为?

当nginx的proxy_pass返回502时,可能有很多原因。 我想要的是能够检测何时返回502,因为没有find上游主机(即,无法parsing)。 我知道proxy_intercept_errors ,但它似乎没有帮助我的情况。 我拥有的 我有一个运行在Kubernetes窗格上的nginx网关服务器。 它被configuration为根据主机名的第一部分将请求路由到适当的Kubernetes服务(在第一个点之前的词,例如service-name.example.com应该路由到称为service-name )。 这是一个简化的configuration部分负责这个逻辑: server { listen 80; resolver 172.16.2.3; // Pod IP address server_name "~^(?<svc>[\w-]+)\."; location / { # Each Kubernetes service has an internal domain name matching the following pattern proxy_pass "http://$svc.default.svc.cluster.local"; proxy_set_header Host $host; # Proxy `X-Forwarded` headers sent by ELB: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/x-forwarded-headers.html proxy_set_header X-Forwarded-For $http_x_forwarded_for; proxy_set_header X-Forwarded-Port […]

使用AWS Elastic Beanstalk上的Spring Bootredirect问题

我刚刚通过弹性beanstalk在aws上放置了一个新的Spring Boot应用程序。 该应用程序拥有自己的静态网站,它承载。 当我在本地运行它时,我可以到localhost:5000并将其redirect到localhost:5000/index.html ,然后使用React路由器为我重写URL,以在localhost:5000/login上显示我的login页面。 但是,在AWS中,访问根URL my-app.us-west-2.elasticbeanstalk.com返回一个403访问被拒绝,这可能是由于我的Spring Securityconfiguration,除非我不明白为什么它不是redirect到my-app.us-west-2.elasticbeanstalk.com/index.html像我所期望的。 什么是最简单的方法来解决这个问题? 这只是一个演示,所以我比最好的长期解决scheme更容易感兴趣。

Nginxconfiguration第三级域名

我知道如何使用htts为网站创buildnginxconfiguration,以便redirect到https域: server { listen 80 default_server; listen [::]:80 default_server; server_name my_domain.com www.my_domain.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name localhost www.my_domain.com; return 301 https://my_domain.com$request_uri; } server { listen 443 ssl default_server; listen [::]:443 ssl default_server; server_name my_domain.com; # ……………. 现在我除了已经有的“my_domain.com”之外,还设置了域名“登台”。 也就是说,“staging.my_domain.com”我应该如何更改“staging.my_domain.com”上面的configuration? 我无法弄清楚。 我应该完全删除第一部分,因为不能有www.staging.my_domain.com 如果没有,那么我的configuration应该怎么样?

对Nginx的Apache ReverseProxy只显示Nginx的默认localhost域

我正在CentOS Nginx上configurationApache ReverseProxy上的Tuleap。 Tuleap在CentOS上成功运行,可以访问。 configuration完反向代理后,我已经使用glassfish和另一个相同的configurationApache服务器工作正常。 但是nginx只显示localhost页面。 查看nginx tuleap主机和apache reverseproxy主机的configuration文件 nginxconfiguration: # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr […]

nginx:来自localhost的奇怪请求在error_log中,access_log为空

我有这些请求nginx,但我不知道是什么造成他们: 网站ssl.error_log: 2017/11/11 05:46:58 [info] 5642#5642: *64 SSL_do_handshake() failed (SSL: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol) while SSL handshaking, client: 127.0.0.1, server: 0.0.0.0:443 2017/11/11 08:16:58 [info] 5642#5642: *122 SSL_do_handshake() failed (SSL: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol) while SSL handshaking, client: 127.0.0.1, server: 0.0.0.0:443 2017/11/11 08:46:58 [info] 5642#5642: *123 SSL_do_handshake() failed (SSL: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol) while SSL handshaking, client: 127.0.0.1, server: […]