Articles of nginx

OPcache打破phpBB注册

我不知道发生了什么,但是当用户试图在我的phpBB论坛上注册自己时,nginx会抛出502 Bad gateway ,但是如果我禁用OPcache,一切正常。 这是来自php-fpm的错误日志: WARNING: [pool www] child 14677 exited on signal 11 (SIGSEGV) after 87782.968736 seconds from start 这是nginx错误日志: [error] 14099#0: *78984 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxxx, server: x, request: "POST /ucp.php?mode=register HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "x.tld", referrer: "https://x.tld/ucp.php?mode=register" 在我的所有主机上启用Pagespeed以及清漆。 Vhostconfiguration: […] # […]

Ngnix用catchall server_name重写

我试图做一个基于catchall服务器名称重写。 所以我想要任何命中该服务器的域名 demo.example.com 被重写 example.org?site=demo.example.com 目前我有catchall服务器设置为 server { listen 80 default_server; server_name ~^(.+)$; location / { rewrite ^ http://example.org?site=$host permanent; } } 不过,上面的configuration是带我去的 http://example.org/?site=~ ^(。+)$ 我已经尝试使用$ server_name在重写也没有运气。 有任何想法吗?

在nginx中使用fastcgi_split_path_info作为userdir

我试图在我的服务器上执行一个PHP文件在url /〜/ / / /~nik/t.php (实际文件在/home/nik/public_html/t.php )。 这是我的PHP设置的样子: location ~ ^/~(.+?)(/.*)\.php$ { alias /home/$1/public_html; # What should this regex be? fastcgi_split_path_info ^/~nik/(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } include fastcgi.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } 我一直得到一个404,当我回答return 404;条款的return 404; ,我可以看到错误: Unable to open primary script: /home/nik/public_html/~nik/t.php (No such file or directory) 你可以看到我的configuration有什么问题,或者指向我有关如何做到这一点的文档? 不幸的是,先进的正则expression式知识是configurationnginx的要求。

nginx在404上重试一次静态文件

在我的testing场景中,如果正在创build一个文件,并且有人请求文件404将被返回。 我想为该文件实施一次重试。 当前configuration location /file/ { root /var/www/html/; try_files $uri $uri/ @retry; } location @retry { proxy_pass http://127.0.0.1; } 这适用于实时文件创build和访问(如果一个文件返回404重试类)。 但如果一个文件不存在,它会创build一个嵌套的请求(我猜),这将最终返回503网关超时。 1)有没有更好的实施呢? 2)当第一个请求超时,嵌套请求也会死掉吗?

WordPress无法写入文件,尽pipe正确的文件权限

我无法自动安装插件或主题在我的新的WordPress的设置。 它给了我这个屏幕: 我相信这通常是由于wordpress目录上的写权限错误。 这些是我迄今为止所做的步骤: nginx在root用户下运行,在nginx用户下有工作进程: # ps -ef | grep nginx | head root 14197 1 0 07:46 ? 00:00:00 nginx: master process nginx nginx 14198 14197 0 07:46 ? 00:00:00 nginx: worker process PHP-FPM在root用户下运行,在nginx用户下有工作进程: # ps -ef | grep php-fpm | head root 14748 1 0 08:38 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf) nginx […]

Nginx位置redirect不当

我的nginx.conf: http { include mime.types; default_type application/octet-stream; # click tracking! access_log /var/log/nginx/nginx.access.log combined; sendfile on; tcp_nopush on; # off may be better for *some* Comet/long-poll stuff tcp_nodelay off; # on may be better for some Comet/long-poll stuff gzip on; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 500; gzip_disable "MSIE [1-6]\."; include /etc/nginx/sites-enabled/*; upstream nvhbase { server unix:///tmp/nvhbase.sock […]

在Apache的nginx不加载图像

我configuration了一个nginx将运行在80,这里的Apache 8081是我的虚拟主机configuration: server { listen 123.123.123.123:80; server_name edm1.mydomain.com mydomain.com; access_log /var/log/virtualmin/edm1.mydomain.com_nginx_access_log; error_log /var/log/virtualmin/edm1.mydomain.com_nginx_error_log; location / { proxy_pass http://123.123.123.123:8081; include /etc/nginx/proxy.conf; } location ~* ^.+\.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mp3)$ { expires 30d; root /home/edm1/public_html } } 当我访问页面,图像将不会加载(如果我删除行的位置,图像将被加载),并保持加载页面(标题栏中的旋转图标),当我打开/ var /日志/ virtualmin / edm1.mydomain.com_nginx_error_log,它说“权限被拒绝”,我该如何解决这个问题?

Nginxcaching节点中的%sys系统利用率很高

我们使用Lua(openresty bundle)设置Nginx作为本地caching节点到我们的文件共享服务器,我们将文件分隔为“每个50MB”(通过这种方法),并将它们存储在caching中以提高效率。 在低stream量下,它工作正常,但随着caching文件和负载的增加(即使不是很高),由于大部分时间系统购买超过80%,caching将无响应。 所以在这种情况下可能会有什么样的performance杀手 虽然我们尝试调整几个参数(即caching目录级别,RAID参数),但我没有给出最佳解决scheme PS。 caching中只有10000个文件后服务器上出现约300个连接/秒的症状 caching服务器规格 1xCPU 2.5 Ghz 12 Cores 128GB RAM 10x500GB Samsung SSD RAID0 (128KB chuck s) storage linux Os -CentOS 6.6 64bit File system ext4 4k block Nginx conf worker_processes auto; events { use epoll; worker_connections 1024; multi_accept on; } http { include /usr/local/openresty/nginx/conf/mime.types; proxy_cache_path /mnt/cache/ levels=2:2:2 keys_zone=default:1000m loader_threshold=100 […]

NGINX反向代理端口

我试图用nginx来实现一个反向代理。 但以上configuration我得到的是在浏览器中的一个错误的url: http://domain:9080/myLocation/something.html 和我需要的是(没有端口): http://domain/myLocation/something.html 组态: location /myLocation { proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://xptoserver:9080$request_uri; }

更正安装在非根目录下的WordPress的nginx虚拟主机?

假设我的主域是example.com。 我在域上安装SSL,并且可以成功访问域。 我的首选版本是使用www,所以所有的请求将被redirect到https://www.example.com 。 这是我迄今为止所做的,并且在访问根域时效果很好。 # redirect HTTP to HTTPS server { listen 80; server_name example.com www.example.com; rewrite ^ https://$server_name$request_uri? permanent; } # SSL conf server { root /var/www/example.com; index index.html index.htm index.php; access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; listen 443 ssl spdy; server_name example.com www.example.com; ssl_certificate /etc/ssl/example.com/certificate/join-cert.crt; ssl_certificate_key /etc/ssl/example.com/server-key/ssl.key; # Redirect non-www to www if ($host […]