Articles of nginx

Nginx的 – 防止.php文件运行在任何东西,但你自己的服务器/域?

我们有一个MP3播放器,通过一个iFrame运行,而不是我们的select,但多数民众赞成我们如何坚持下去。 我们希望阻止其他人在他们的网站上embeddediframe。 什么是最好的方法来做到这一点? 我们正在运行nginx,所以没有.htaccess。 MP3播放器是由PHP文件组成,我们需要继续在iframe中运行它。 反正有locking特定的MP3播放器的PHP文件(在这种情况下html5player.php)只能够在我们的服务器或域名执行? 在nginx中肯定有办法做到这一点? 但是,当然,如果他们embedded的iFrame它会认为它是在我们的服务器运行不pipe呢? 我想到的所有解决scheme都在某个地方跌倒了,所以非常感激。

Varnish不能正确地将用户IP传递给MediaWiki

我正在使用Nginx,FastCGI,APC,Memcache和Varnish来运行MediaWiki安装。 我有一些问题,最近的更改显示为来自127.0.0.1的匿名用户。 我怀疑问题是,Varnish没有正确地将用户IP传递给Nginx,但是我在vcl_recv中有这个function: # Set client IP if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; } else { set req.http.X-Forwarded-For = client.ip; } 任何人都可以告诉我什么,我可能需要validation,可能会导致这个问题? 因为我不知所措

如何使Zend 2和Nginx工作?

我试图让我的Zend2应用程序与Nginx而不是Apache一起工作。 我search了一个WWW的解决scheme,但没有find关于Zend 2和Nginx的东西,我发现所有的东西都是如何使旧的zend(1)框架与nginx一起工作的旧的旧post。 与所有新的zend 2应用程序一样,我尝试将nginxconfiguration指向/ projectdir / public,并尝试了其他方法,从/ projectdir / public到/ usr / share / nginx / www创build一个符号链接,工作。 PHP5FPM被安装和configuration,phpinfo()工作。 这是我最后的尝试,使事情工作看起来像… 这是我的/ etc / nginx / sites-available / default server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www/; index index.php index.html […]

php-fpm和nginx:找不到文件

我有一个非常常见的,但烦人的错误,古典:“文件未find”。 我有以下nginx.conf: server { listen 80; server_name aperophp; root /home/gline/mysite/web; location = / { try_files @site @site; } location / { try_files $uri $uri/ @site; } location ~ \.php$ { return 404; } location @site { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/index.php; fastcgi_param PATH_INFO $fastcgi_script_name; } } 但是我有这个文件: $ ls -ld /home/gline/mysite/web/index.php -rw——- 1 […]

Nginx的位置和重写

我正在处理以下问题,我无法解决它。 我在运行nginx的应用程序服务器场前面有HAproxy。 HAproxy为后端服务启用了一些httpchecks – 检查命中/ health_check URI: option httpchk HEAD /health_check HTTP/1.1\r\nHost:\ staging.example.com 我想不出的是如何避免为所有URI启用永久重写的虚拟主机的日志logging。 这里是例子 server { listen 8000; server_name ""; location = /health_check { access_log off; return 200; } rewrite ^(.*) https://staging.example.com$1 permanent; } 我以为上述位置指令将禁用给定的URI日志,但我错了 – 它被完全忽略。 有什么办法如何去实现这样的事情?

Nginx作为负载平衡器 – 没有响应的请求会发生什么?

我有2个PHP应用程序的VPS服务器都使用相同的数据库(在第三台服务器上)。 我想有第四个服务器,只有nginx作为负载平衡器,试图“分”在两个stream量。 我的问题是 – 如果nginx收到一个请求,试图将其转发给其中一台服务器,但服务器没有响应,会发生什么情况。 它会尝试将其发送到第二台服务器吗? 重要的是我没有一个单一的丢失的请求,所以如果Server1失败,Server2将立即收到相同的请求。 这是如何nginx的作品? 如果没有,我可以用nginx来做吗,或者我应该尝试使用另一种解决scheme? 问候。

nginx重写规则从子域的服务器图像?

我希望我的所有图像(jpg | gif | png)目前从mydomain.com/files/被服务器从我从static.mydomain.com设置到服务器文件的第二台机器上被切断。 我想知道如何定义nginx重写规则来做到这一点? 谢谢

将url映射到子网域(NGINX)

我知道这个问题之前已经问过,但我有麻烦复制它在我的服务器上。 我想要做的是当用户去medicine.example.com ,该子域应该映射到example.com/sites/medicine 。 所以用户看到的URL是medicine.example.com 。 index.php通过php被剥离。 理想的情况下,解决scheme将是一个基于通配符/正则expression式,这样不仅medicine.example.com可以映射到url。 下面的代码给了我一个502 bad gateway错误。 server { listen 80; listen 443 ssl; server_name medicine.example.com; location / { rewrite ^([^.]*[^/])$ $1/ permanent; proxy_pass_header Set-Cookie; proxy_pass https://example.com/sites$request_uri; } }

带有proxy_pass和本地静态caching的Nginx不会提供来自代理位置的图像

早上好, 所以,我现在遇到的问题是我想要这个设置工作: http://qwe1.com/ 这个请求应该去Apache,并从静态内容文件夹中获取所有的图像,这个configuration工作得很好。 http://qwe1.com/forum 这个请求应该被代理到server2(proxy.qwe1.com),现在也工作得很好。 http://qwe1.com/forum/example.jpg 这个请求也应该被代理到server2,因为它必须与同一个论坛做,由于静态caching指令,今天不工作。 它匹配静态caching指令,并尝试在磁盘上本地查找映像,并在static.error.log中给出了一个404,您可以在下面看到。 如果我注释掉静态caching指令,我会得到所需的设置,但是我当然想要运行该caching。 我尝试用重写的帮助来分类,到目前为止我已经尝试了这些解决scheme location ~* ^(?P<part_uri>/forum/.*\.(css|js|jpg|jpeg|png|swf|gif|svg|ttf|eot))$ { proxy_pass http://proxy.qwe1.com/forum_en$part_uri; proxy_redirect off; proxy_set_header Host $host; access_log /var/log/nginx/TMP.log; error_log /var/log/nginx/TMP.log; } 这个解决scheme基本上把从http://qwe1.com/forum到http://qwe1.com/的所有东西都转发了出来,但是我没有真正弄清楚为什么,至less这是行不通的。 我也试过这个解决scheme rewrite ^(/forum/*\.(css|js|jpg|jpeg|png|swf|gif|svg|ttf|eot))$ /forum_en/$1; location /forum_en { proxy_pass http://proxy.qwe1.com; proxy_redirect off; proxy_set_header Host $host; access_log /var/log/nginx/TMP.log; error_log /var/log/nginx/TMP.log; } 这与之前的版本具有相同的症状,我从http://qwe1.com/forumredirect到http://qwe1.com/ 任何想法的人? 我在这里有整个configuration。 提前致谢。 ## one.qwe1.com = server1 […]

nginx + php-fpm“连接()失败”日志中的错误,没有可见的影响

我想弄清楚为什么我有这么多的错误日志: [error] 1545#0: *713626 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: www.example.com, request: "GET / HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "www.example.com" 所有关于这个错误的post,我已经看到了导致坏的网关错误,但是我已经快速浏览了网站上的许多页面,试图得到错误popup,果然,最新的日志显示这个错误与我的IP。 不过,我从来没有任何问题获得任何页面加载。 这个问题可能是什么? nginxconfiguration: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # output compression saves bandwidth gzip on; gzip_static on; […]