Articles of nginx

使用NGINX将特定文件夹的IP列入白名单(又名example.com/administrator)

我正在寻找一种方法来将我的网站的特定区域的一组特定的IP地址列入白名单。 例如,我想只允许xxx.xxx.xxx.xxx访问“example.com/admin”,并拒绝所有其他的IP – 我认为这将发生在实际的服务器{}部分,但不知道在哪里和如何pipe理这个。

为什么使用“root”比在nginxconfiguration中使用“别名”更好?

我经历的所有post都认为使用root和alias指令有时会导致类似的结果,如下例所示: 使用alias指令: location /images/ { alias /data/w3/images/; } 使用root指令: location /images/ { root /data/w3; } 所有的事情都是平等的,我个人更喜欢使用alias有$document_root指向实际的文档根目录,而不是其父目录,并限制讨厌的问题,我会错误地忘记尾部/在location值。 但是, nginx文档明确指出,在这种情况下: 取而代之的是使用root指令 为什么这样? 虽然我看到赞成alias论据,但我不明白为什么root是首选的?

如何设置nginx索引

这里是基于端口4000服务的服务http://example.com ,我现在可以访问http://example.com/index.html 。 当我访问http://example.com ,我也想要访问index.html 。 这是我的nginx设置: map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name example.com ; location / { root /wwwroot/product/example.com/programs/web.broswer/app; index index.html; proxy_pass http://localhost:4000; # 映射到本地端口#proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # configuration支持websocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } […]

在Nginx中configuration的网站返回404错误

我有一台使用Nginx的Amazon EC2机器。 我有MediaWiki运行,我想在同一台服务器上使用Phabricator(另一个应用程序)。 我的Phabricatorconfiguration文件是: server { server_name phabricator.example.com; root /var/www/phabricator; location / { index index.php; rewrite ^/(.*)$ /index.php?__path__=/$1 last; } location = /favicon.ico { try_files $uri =204; } location /index.php { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; #required if PHP was built with –enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; #variables to make the $_SERVER populate in PHP fastcgi_param SCRIPT_FILENAME […]

NGINX – rewrite_log不工作日志在任何地方重写

我试图学习重写,通过做这样的事情: ^/blog/install/(.*)$ –> /blog/install/index.php?_p=$1 然而,这些重写只是保持失败,很难调查,所以我看了,发现rewrite_log on作为一个适当的function来帮助我。 我的服务器块中的error_log被设置为notice级别按照NGINX指南,但是无论我放置rewrite_log on和重新加载它将永远不会logging任何有关重写,只有nginx / php错误! 我试图甚至设置error_log debug它会给我的唯一相关的信息是以下行: 2015/12/14 13:46:26 [debug] 17458#0: *4494 http copy filter: 0 "/blog/install/index.php?_p=" 2015/12/14 13:46:26 [debug] 17458#0: *4494 http finalize request: 0, "/blog/install/index.php?_p=" a:1, c:1 然而,围绕它的任何东西(包括谈论SSL和HTTP过滤的行)都提及了_p=或者全部。 一些testing,我已经用于重写,我已经尝试了许多组合: location /blog/install { try_files $uri $uri/ @install; } location @install { fastcgi_pass unix:/var/run/php5-fpm-site_mainsite.sock; fastcgi_param SCRIPT_FILENAME $document_root/blog/install/index.php; fastcgi_param QUERY_STRING _p=$uri&$args; […]

WordPress上的两个独立的服务器,第一个与nginx,第二个与php-fpm。 在哪里保持静态文件?

例如,我有两台服务器(或VM)。 第一个是我安装了Nginx,第二个是PHP-FPM。 我需要部署一些应用程序,比如WordPress,它没有两个单独的文件夹用于脚本和静态文件,有时脚本可以写入静态文件。 这个怎么做? 据我所知,我应该在后端服务器上保留脚本,但是我应该如何处理静态文件? 我应该保留在这两个服务器上的所有文件(脚本+静态),并同步它们? 那我怎么能同步他们? 或者我应该只在后端保留脚本,而只在前端保持静态? 但是,如果某些脚本想要访问某个静态文件或写入,会发生什么? 还是应该在后端服务器上设置第二个Nginx实例,并将后端nginx的静态文件提供给前端nginx,然后将其caching到前端的磁盘上? 我知道,应该有不止一种方法来设置这个,我只是想听听人们通常如何做这个,为什么。 谢谢!

当读取来自上游文件的响应头时,以stderr发送的fastCGI:“主脚本未知”存在

我已经看了其他的答案,但我仍然没有看到这些configuration的问题: user nginx; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; # Metadata cache open_file_cache max=10000 inactive=5m; open_file_cache_valid 2m; open_file_cache_min_uses 1; open_file_cache_errors on; # Buffer client_body_buffer_size 10K; […]

Docker:Nginx和hhvm套接字configuration返回502 Bad Gateway

我试图运行docker-compose和套接字文件configurationnginx和hhvm,但它返回一个502错误。 我可以访问conf / hhvm /运行/从nginx和hhvm图像。 在error.log nginx的文件中,我得到: [error] 5#5: *3 connect() to unix:/var/run/hhvm/hhvm.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/hhvm/hhvm.sock:", host: "xxxxxxx.io", referrer: "http://xxxxxxx.io/" docker构成文件: nginx: image: nginx restart: always ports: – 80:80 log_driver: syslog links: – hhvm volumes: – ./www:/var/www/wp:rw – ./conf/nginx:/etc/nginx:rw – […]

nginx乘客,设置umask

我想知道如何设置umask的nginx或乘客或两个进程。 search似乎只会带来Apache。 任何帮助将非常感激! (这在Debian上)

如何为nginx发送的每个html设置特定的键值对,而不会损失其他键值对?

我想使用nginx在每个html的searchstring中设置mode的值。 我写这样的代码: if ( $arg_mode !~ test ){ rewrite ^(?:/(.*)\.html)?$ /$1.html?mode=test? redirect; } 但是会造成其他键值对的丢失。 例如,如果我请求的url http://xxx.xx.xx/weather/bug.html?code=12345&mode=mess 我打算得到 http://xxx.xx.xx/weather/bug.html?code=12345&mode=test 但是我明白了 http://xxx.xx.xx/weather/bug.html?mode=test 代替。 键值对代码= 12345丢失。 我怎样才能解决这个问题?