我正在运行nginx / 1.1.19: # nginx -V nginx version: nginx/1.1.19 TLS SNI support enabled configure arguments: –prefix=/etc/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-log-path=/var/log/nginx/access.log –http-proxy-temp-path=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –lock-path=/var/lock/nginx.lock –pid-path=/var/run/nginx.pid –with-debug –with-http_addition_module –with-http_dav_module –with-http_geoip_module –with-http_gzip_static_module –with-http_image_filter_module –with-http_realip_module –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-http_xslt_module –with-ipv6 –with-sha1=/usr/include/openssl –with-md5=/usr/include/openssl –with-mail –with-mail_ssl_module –add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam –add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo –add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair –add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module 我正在使用它来反向代理服务,可以stream数据作为分块的响应。 后端服务中的每个块都是一个有效的JSON文档,但是当通过nginx代理访问时,块被重新打包成'round'大小,如0x1000,0x2000,0x4000等。这使得块不再有效的JSON blob,每个块将在开始时具有一个文档的结尾,并在结尾处具有另一个文档的开头。 我的location块是这样configuration的: location / { proxy_pass http://backend; […]
我有nginx设置为一个Flask应用程序uWSGI服务。 有时会出现错误,或者我将重新启动uWSGI服务,但是我希望nginx提供更好的维护页面,而不是在uWSGI没有响应时发生的默认502错误网关。 我已经尝试了多个configuration,应该这样做,但没有一个似乎有任何效果。 这是我目前的configuration: server { listen 80; server_name mydomain.com; charset utf-8; client_max_body_size 75M; location / { try_files $uri @flask; error_page 502 =200 @maintenance; } location @flask { include uwsgi_params; uwsgi_pass unix:/path/to/socket/uwsgi.sock; } location @maintenance { root /path/to/web; rewrite ^(.*)$ /maintenance.html break; } }
我的服务器当前正在超时,当我尝试查看该网站。 我试过重新启动nginx。 我试过重启php-fpm。 我试过重新启动MySQL。 没有骰子。 我尝试重新启动盒子。 还没有骰子。 我最近没有应用任何更新。 我应该在哪里寻找/我应该运行什么testing来解决这个问题? nginx错误日志充满了: “上游超时(110:连接超时)连接到上游” 静态文件(.jpeg,.html等)似乎工作正常,所以这是一个PHP的问题,我假设。 编辑:修正,见下面的评论
我是nginx的新手,但是我遇到了一个对我来说完全不明显的基本问题。 我在我的Mac上使用brew安装了nginx。 这工作得很好,这个基本的,不变的默认configuration: server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } 现在,我是一个开发多个项目的开发人员。 以前我在apache中为每一个虚拟主机configuration了一个虚拟主机,与myproject1.local这样的自定义主机条目结合在一起。 所以,为了用nginxtesting这个,我编辑了我的/ etc / hosts文件并添加了: # /etc/hosts 127.0.0.1 mytestproject.local 然后,在nginxconfiguration中,我添加了以下内容: server { listen 8080; listen mytestproject.local:80; server_name mytestproject.local; location / { root […]
我正在尝试为特定的目录( /api/ )禁用basic_auth,但仍然对我正在使用的网站的其余部分进行基本身份validation。 以下是我的nginx.conf : server { # base settings listen 80; server_name somesite-somewhere-anywhere.com; root /var/www/wordpress; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; } # setup logs access_log /var/log/nginx/somesite-somewhere-anywhere.com.access.log; error_log /var/log/nginx/somesite-somewhere-anywhere.com.error.log; # setup 404 error_page 404 /404.html; location /404.html { internal; } # map 403 to 404 error_page 403 = […]
我需要使用一个NGINX实例来支持多个域,但总是第一个列出的域抓取请求。 例如,我有如下。 但是,当客户端请求beta.com时,nginx服务器会回应alpha.com页面。 哦,我已经阅读了其他类似的post,并试图取消注释 server_names_hash_bucket_size 64; 但它没有帮助。 cd /etc/nginx # ls sites-enabled alpha -> /etc/nginx/sites-available/alpha beta -> /etc/nginx/sites-available/beta # cat sites-available/alpha server { listen 80; #listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html/alpha; index index.html index.htm; server_name alpha.com *.alpha.com; location / { # First attempt to serve request as file, then # as directory, then fall back […]
我试图proxy_pass到一个Apache2实例使用命名的位置,但Nginx试图find磁盘上的指定位置? Nginxconfiguration: root /var/www; location / { try_files $uri @apache =404; } location @apache { proxy_intercept_errors on; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } 试图访问一个不存在的文件应该是proxy_pass,但是404会失败,日志显示: trying to use file: "@apache" "/var/www@apache" 这是一个命名的位置,为什么它试图将其作为文件path来读取?
我只在子目录上发生500内部服务器错误。 例如,如果我的网站是example.com,则example.com/index.php起作用。 但是example.com/phpbb/index.php不起作用。 它只是变成一个空白的PHP页面。 HTTP头显示HTTP错误500内部服务器错误。 如果我inputexample.com/phpbb/index.php/somedirectory,我的根目录的index.php就会显示出来。 这一切都很奇怪。 我试过search等,但没有任何工作。 尝试重新安装nginx但不固定。 我确定我的DNSconfiguration正确。 更多的规范:1)Nginx返回一个HTTP 200 OK头,但发送一个0kb(空)PHP文件 – >我只看到一个空白的白屏2)当我去的子目录,主网站加载。 EX)如果我进入example.com/blog/,而不是生成一个404错误,example.com加载。 3)Nginx忽略子目录中的所有.php文件。 HTML和CSS,JS工作正常。 4)没有生成错误日志。 即使PHP没有加载,错误日志是空的。 5)PHP5-FPM在主网站(example.com)上正常工作6)我使用SSL(链) 我的Nginxconfiguration /sites-available/example.com server { server_name www.example.com; return 301 https://example.com$request_uri; } server { listen 443; listen 80; #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen […]
我正在用Nginx写一些干净的URL实现的PHP CMS代码。 为了提高我的代码的安全性,我想重写我的根目录中的所有请求/使用以下types: rewrite ^(.*)$ /index.php?q=$1 last; 有了这种重写,其余的PHP脚本将无法从用户的一面访问(他们将只有,如果包括在PHP中,我是吗?)。 但是,我不想在一个位置重写请求(因为我/static/ ),因为我将只提供静态内容,如图像和CSS从该位置。 我怎样才能使这个重写不能在某些地方工作?
我有平常的 proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=drupal:16m; proxy_cache_key "$scheme$host$request_uri"; build立代理caching。 我应该如何configurationnginx以允许通过HTTP请求从caching中删除特定项目?