Articles of nginx

Nginx前端和wp-admin / admin-ajax.php:debugging500个错误

每个小时左右,我开始在wp-admin和wp-admin / admin-ajax.php上得到500个错误。 我运行DSO + APC + Nginx(admin)+ Apache。 Apache在8080端口和Nginx上运行。 我到目前为止所做的: 我开始研究debug.log,并照顾一些不时发生的致命的崩溃 我添加了0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client因为我的日志显示tmp inode全部用完并崩溃nginx 检查其他问题,并将PHP memory_limit提高到128M 出于某种原因,我的wp-admin文件夹被分配给用户1001,我将其更改回nobody:nobody(nginx当前以nobody身份运行) 我正在为Nginx前端使用以下vhostsconfiguration: # BEGIN W3TC Page Cache cache location ~ /wp-content/cache/page_enhanced.*html$ { add_header Vary "Accept-Encoding, Cookie"; add_header Pragma "no-cache"; add_header Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"; } location ~ /wp-content/cache/page_enhanced.*gzip$ { […]

最好的方式来pipe理单个液滴的SSL多个域?

对于我可怜的英语抱歉抱歉,但我会尽我所能。 目前,我pipe理我的$ 5 DigitalOcean飞机上的2域,并使用Cloudflare作为我的DNSpipe理器灵活的SSLconfiguration,一切工作正常,直到我决定改变到完全SSLconfigurationSSL证书从Cloudflare(博客[dot] cloudflare [dot] com /通用的SSLencryption,所有的路到了原产地换免费/)。 比方说,我的域名是domain.com和example.com 。 当我通过HTTP访问它们都看起来很好。 http; // example [dot] com :显示来自example.com的正确的内容, 它是WP站点 http; // domain [dot] com :显示来自domain.com的正确内容,即Jekyll生成的HTML网站 但是,当我尝试从HTTPS访问它时,看起来很奇怪。 https; //示例[dot] com :显示来自example.com的正确内容,即WP站点 https; //域[dot] com :显示来自example.com的WP内容? 在这里我的nginx example.com.conf server { listen 80; listen 443 ssl; server_name example.com; root /var/www/sites/example.com/; # Logging Settings access_log /var/www/logs/example.com-access.log; error_log /var/www/logs/example.com-error.log; location / […]

nginx:使用带有允许/拒绝指令的地理模块

阅读nginx的ngx_http_access_module的文档,我碰到这个: 在很多规则的情况下,使用ngx_http_geo_module模块variables是可取的。 我怎样才能使用地理模块的允许/拒绝? 如果我这样做: geo $listofips { default 0; 8.8.8.8 1; } server { # […] allow $listofips; deny all; } 它给了我以下错误: 无效参数“$ listofips”在/path/到/configuration:97 如何使用地理模块进行访问控制? 我不能使用ifs,因为它显然会中断try_files (请参阅nginx的IfIsEvil)。

php5-fpm与nginx会话没有维护/随机丢弃

当用php5-fpm运行nginx时,会话variables会随机丢失它们的值。 由于我的会话variables变为空,我的脚本要求用户再次login。 然而,奇怪的是会话没有被销毁或未设置。 我将其添加到我的脚本的索引: session_start(); if(isset($_SESSION["my_count"])){ $_SESSION["my_count"] = $_SESSION["my_count"] + 1; }else{ $_SESSION["my_count"] = 0; } echo "<p>Session my count is equal to: " . $_SESSION["my_count"] . "<br>My session id is: " . session_id() . "</p>"; 当我再次login时,会话variables应该被设置并且有值。 不幸的是,他们没有,我的脚本输出0.然而,它总是输出相同的session_id是正确的。 如果我重新启动php5-fpm和nginx: systemctl restart php5-fpm systemctl restart nginx 然后一切按预期工作,会话variables保持不变,直到我访问我的浏览器的另一个选项卡中定义的服务器主机之一。 例如,我有nginx的test.com设置(我没有域名,但我的主机文件被设置为直接返回到我的本地服务器),如下所示: server { listen 80; server_name test.com www.test.com ; […]

使用Nginx的SubDirectory中的WordPress

无论我做什么,我的WordPress网站的工作很好,包括所有永久链接,但我无法访问wp-admin区域。 每当我尝试这样做,我得到一个404错误。 我已经将WordPress安装到自己的目录中,简称为“WordPress”。 这是我的configuration文件: server { listen 443 ssl; server_name my-domain.com; root /home/wp-user/my-domain.com/public; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; index index.html index.htm index.php; charset utf-8; # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location […]

NGINX页面上的随机403错误和静态图像

我有一个与NGINX随机403错误的问题。 在一个页面“profile / user.name.1”我有静态图像,但他们没有加载。 我收到以下消息: "Failed to load resource: the server responded with a status of 403 (Forbidden)". 当我尝试从这个页面明确地到达另一个页面时,我得到一个“403 Forbidden”消息。 我用用户“nginx”运行nginx,我试着用“myuser nginx”运行它, http://nicholaso​​rr.com/blog/2008/07/22/nginx-engine-x-what-a-pain-in-在-stream浪汉/ 这个图像文件夹的权限是: drwxr-xr-x 2 myuser nginx 4096 5 jun 20:54 pics 我的index.php文件的权限是: -rwxr-xr-x 1 myuser nginx 2517 11 jun 23:34 index.php 编辑:当我检查整个path的权限,与: namei -mo /usr/share/nginx/html/myuser/public/img/pics 我有: drwxr-xr-x root root / drwxr-xr-x root root […]

如何设置Nginx在单个站点上使用ssl / non-ssl作为不同的URL,但如果用户在浏览器的地址栏中inputhttps,则始终使用ssl?

我现在的nginx.conf看起来像这样: server { listen 80; server_name www.example.com; root /var/www/; location / { } location /users { rewrite ^ https://$http_host$request_uri? permanent; } } server { listen 443 ssl; server_name www.example.com; root /var/www/; location /users { } location / { rewrite ^ http://$http_host$request_uri? permanent; } } 通过这种configuration,当用户在网站上浏览页面时,连接从/切换到ssl / non-ssl,对于urls以/users开始,对于所有其他urls,non-ssl为ssl。 因此,即使用户在浏览器的地址栏中明确键入了https://www.example.com/ ,结果页面也会redirect到http://www.example.com/ 。 有没有一种方法来实现上述设置实现的ssl / non-ssl之间的自动url重写,但仍然尊重明确的ssl请求,如果https://是用户在浏览器的地址栏中显式键入?

gunicorn从terminal和服务运行时performance不同

我为我的网站使用nginx + gunicorn + django。 以下是我的gunicorn.conf文件: description "Gunicorn daemon for Django project" start on (local-filesystems and net-device-up IFACE=eth0) stop on runlevel [!12345] # If the process quits unexpectadly trigger a respawn respawn setuid django setgid django chdir /home/django # export LC_ALL=en_US.UTF-8 # export LC_LANG=en_US.UTF-8 # export LANG=en_US.UTF-8 exec gunicorn \ –name=eduwiki \ –pythonpath=eduwiki \ –bind=0.0.0.0:9000 […]

NGINX HTTPS反向代理 – 快速TTFB但并发性低

我有一个运行的应用程序:NGINX(SSL)=> VARNISH(CACHE)=> APACHE / PHP。 运行ab基准testing ,我能够通过EC2 t2.small实例在清漆层(通过HTTP)实现30k +请求/秒。 然而,当我通过NGINX(HTTPS)运行testing时,我只能够推送160个请求/秒(来自公共networking的TTFB的平均值为43ms)。 @ nginx.conf user nginx; worker_processes auto; worker_rlimit_nofile 65535; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 16024; multi_accept on; } 并在http级别: sendfile on; tcp_nopush on; keepalive_timeout 10; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; @ domain.conf server { listen 443 ssl; server_name xyz.com; ssl_certificate /home/st/ssl3/xyz.crt; ssl_certificate_key /home/xyz/ssl3/xyz.key; ssl_protocols TLSv1 […]

空格在nginx conf文件中是否重要?

我有一个nginx conf文件,由于使用环境variables,我有一个shell脚本回声,这个文件我称为nginx.conf.template ,然后我把回应的结果放到实际的nginx.conf ,请参阅shell脚本bellow: #!/bin/sh function subst() { eval echo -E "$2"; } mapfile -c 1 -C subst < nginx.conf.template > nginx.conf 我唯一的问题是,它删除所有的缩进空白,我想这会造成一个问题,但是我运行这个nginx服务器的docker容器似乎很好。 我没有缩进是否重要? 如果它确实重要,可以回声保留所说的空白?