Articles of nginx

nginx上有多个ssl主机

我有一个服务器与Nginx的多个ssl网站,虚拟主机像这样工作: root / var / www / html / $ host; 但是在证书部分,$ hostvariables不起作用: ssl_certificate /etc/nginx/ssl/$host.crt; ssl_certificate_key /etc/nginx/ssl/$host.key; 我如何解决这个问题?

Android上的Chrome发布Nginx提供的静态MP3文件的双字节范围请求

我正在用Nginx托pipe一个2.9MB的MP3文件。 当我在Android上使用Chrome导航到其URL时,有两个请求:一个正常请求和一个两字节范围请求。 当我将第一个请求作为cURL命令复制并在Mac OS X上执行时,它将整个下载文件。 但是,在Android上,只有3.7KB在双字节范围请求被触发之前下载。 Nginx乖乖地回应只有两个字节的数据,并且Chrome中显示的audio控件不起作用。 我试着设置max_ranges 0 ,禁用etags,gzip等。我似乎无法让Chrome下载文件的其余部分。 第一个要求: GET /yt/test.mp3 HTTP/1.1 Host: xxx.xxx.xx.xxx Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.95 Mobile Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 响应: HTTP/1.1 200 OK Server: nginx Date: Mon, […]

nginx用wordpress重写链接

我已经断开了我的WP博客上的链接,这是在这条路线上 www.site.com/wp-content/plugins/download-monitor/download.php?id=1 但是,当我想重新定向到完全新的网站,我的重写规则不起作用。 我用这个 rewrite ^(/wp-content/plugins/download-monitor/download.php?id=1)(.*)$ http://link.com/my.pdf$2 permanent;

nginxredirect使用可能不存在的映射文件

我正在尝试使用与此问题中讨论的方法非常相似的技术来设置nginxredirect。 我还使用以下代码设置了默认值: map $arg_request_id $url_prefix{ default /old; include /a/b/c/redirect_urls.map; } 默认情况下是我想在出现任何问题时应该回退的内容。 redirect_urls.map文件定期更新。 现在,我遇到的问题是,有些情况会出现问题,redirect_urls.map文件被删除(或者它是一个没有redirect_urls.map文件的新机器)。 我面临的问题是,当我跑步 >>> nginx -s reload nginx: [emerg] open() "/a/b/c/d/redirect_urls.map" failed (2: No such file or directory) in /etc/nginx/nginx.conf:22 我怎么能这样,如果该文件不存在,那么nginx只是拿起默认值,只是总是将$ url_prefix设置为/旧,而不是给一个文件未find错误? 在这种情况下try_files会有帮助吗?

Nginx具体重写

我很困惑在nginx重写。 请帮助我,如果可以..谢谢 xxxx.conf #vhost-xxxxx server { listen 80; server_name xxxx.xxxx.com; root /var/www/html; index index.php index.html index.htm; charset utf-8; access_log logs/xxxxxx.access.log; } #rewrite if (!-e $request_filename) { rewrite ^(.+)$ /cn/index.php?q=$1 last; } location ~ \.php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 你好,我的nginx指向/ var / www / html根目录下的/ var […]

Nginx – 侦听多个域名,只在一个域名上提供一些内容

我有一个服务于2个不同域的Web应用程序,我们称之为eu.example.com和us.example.com 。 我在应用程序的前面设置了nginx,在这两个域上监听: server { listen 443 ssl; server_name eu.example.com us.example.com; … } 现在美国队决定他们想在us.example.com/blog上有一个博客,它应该指向另一台服务器上的WordPress。 我可以通过添加一个新的位置指令到我的nginx服务器configuration来达到这个目的: location /blog { proxy_pass https://us-wordpress.example.com/blog; } 问题是美国博客现在也可以从eu.example.com/blog 。 我试图包装在一个if: location /blog { if ($hostname = us.example.com) { proxy_pass https://us-wordpress.example.com/blog; } } 但是后来我从nginx得到一个错误: "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" […]

Nginx没有服务器子文件夹的API应用程序(PHP-FPM)

我有我的应用程序,位于地图/ /home/valor/development/mypp.com/public_html/ – css – app – js – … – server (codeigniter) — system — application — index.php – index.html (angularJS app) 这是我的nginx.conf server { listen 80; listen [::]:80; root /home/valor/development/euro-swap.com/public_html; index index.html; server_name euro-swap.com www.euro-swap.com; location / { index index.html; } location /server/ { index /server/index.php; try_files $uri /server/index.php/$uri; } location /twitter/ { […]

摆脱nginxconfiguration中的if指令

我有一个Django的应用程序,它有nginx作为一个反向代理与gunicorn作为一个应用程序的Web服务器(上游)。 在我的nginx虚拟主机文件的location /块中,我指的是Web应用程序服务器中的unix套接字,如下所示: if (!-f $request_filename) { proxy_pass http://application_server; break; } 想法是不需要得到gunicorn服务静态资产,nginx应该照顾他们。 我有两个相关的问题:1)性能明智,有这样的types检查nginx可能是昂贵的。 你有没有看到你的经验? 我的networking应用程序是一个高stream量的社交论坛和大量的静态资产需要服务。 想法,做和不(如果有的话)? 需要更多信息? 2)很好的certificate, 如果在nginx的情况下是邪恶的。 如何用try_files更改if指令? 我自己开了一枪。 它看起来很直接。 但是每次都会坠毁和烧毁。 这是我的尝试: 用try_files $uri @application_server;replace整个if指令try_files $uri @application_server; 在location /下包含location @application_server块; 这包含proxy_pass http://application server 。 在configuration文件的顶部有一个upstream application_server块(外部server ),它包含了对unix socket的引用, fail_timout=0; 。 应该有效,不是吗? 如果您需要,请询问更多信息。

处理1个请求时调用Nginx两台服务器

在nginx日志中看到这个: "upstream": "52.86.112.192:443, 52.86.78.197:443", "upstream_response_time": "7.005, 7.016", nginx的文档说: If several servers were contacted during request processing, their addresses are separated by commas, eg “192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock”. 不幸的是,我不清楚在处理1个请求时如何调用两个服务器? 这是没有内部redirect? 第一次尝试失败后是否重试? DNS查询返回两个Alogging: xxx.us-east-1.elb.amazonaws.com. 60 IN A 54.84.139.107 xxx.us-east-1.elb.amazonaws.com. 60 IN A 52.71.207.21 这是否意味着,比nginx自动重试每个失败的请求? 还是可以configuration? (这是AWS,因此负载均衡器的IP不断变化)

nginx上游不能正常工作

代理服务器在同一端口上绑定多个主机名时, upstream不起作用。 我在尝试configurationnginx(1.9.12-1〜trusty)到proxy_pass Windows Server 2012主机时遇到了这个问题。 我已经在我自己的Windows 10机器上复制了相同的行为。 在下面的configuration中,所有主机名都指向相同的机器IP。 有时需要工作 注意:我是在selectlocalhost:7778时候进行代理的。 http { upstream w { server test1:80; server test2:80; server localhost:7778; } server { listen 8001; server_name localhost; location / { proxy_pass http://w; } } } 请求没有工作的时间 注意:如Alexey指出的那样编辑。 http { upstream w { server test1:80; server test2:80; # server localhost:7778; } server { listen […]