Articles of nginx

Nginx挂起使用“服务nginx启动”

我编译nginx与我的生产服务器的自定义path,当我尝试启动/重新启动服务使用: service nginx start 要么 service nginx restart 它在不返回shell的情况下进入一个新行: 所以问题是我不能使用service命令来控制nginx。 该服务实际上运行,但它不会返回一个壳给我,所以我总是不得不按Ctrl + C把它拿回来。 我也不得不提到nginx运行得很好,当它通过自己的nginx命令调用它,并停止或重新加载容易使用nginx -s stop/reload 。 这个问题仍然使用systemctl start nginx ,但systemctl stop nginx工作得很好。 信息: $ lsb_release -a Distributor ID: Ubuntu Description: Ubuntu 15.10 Release: 15.10 Codename: wily $ uname -r 4.2.0-27-generic $ nginx -V nginx version: nginx/1.9.11 built by gcc 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) built […]

如何configuration一个位置块来始终返回nginx中的单个文件?

在我的应用程序中,我希望位置“/”返回一个静态index.html文件,我想要“/静态”来提供文件夹中的静态文件,我希望所有其他请求返回404 NOT FOUND。 稍后,我将把所有其他请求redirect到WSGI服务器。 这是目前我的configuration: # Dev server. server { listen 1337; charset UTF-8; location / { rewrite ^ static/index_debug.html break; } location /static { alias /home/tomas/projects/streamcore/static; } } 静态文件夹工作正常,但“/”返回404未find。 我也试过了: alias /home/tomas/projects/streamcore/static/index_debug.html; 在位置块中,但返回500内部服务器错误。 好像alias不喜欢单个文件。 另外我试过了: try_files static/index_debug.html; 但是,这会阻止服务器从错误“try_files指令中的参数数量无效”开始。 显然try_files实际上需要你尝试多个文件,这不是我正在寻找的行为。 所以我的问题是: 如何configuration一个位置块,始终返回一个静态文件? 编辑:我从其他答案看到alias应该确实接受一个文件作为参数,所以我试过: location = / { alias /home/tomas/projects/streamcore/static/index_debug.html; } 但我仍然只能得到500内部服务器错误。 “/”请求的错误日志说: [alert] 28112#0:* 7“/home/tomas/projects/streamcore/static/index_debug.htmlindex.html”不是目录 […]

将用户名存储在nginx日志中

有没有一种方法可以将用户名或用户标识存储在nginx日志中。 我试图在log_format指令中插入$ remote_user,但似乎不起作用。

如何在openssl cli中指定subjectAltName?

我正在生成一个自签名的SSL证书: $ openssl req -x509 -newkey rsa:2048 -subj 'CN=example.com' 我想在创build时指定一个subjectAltName ,但是在openssl的manpage中找不到关于如何执行的信息。

长时间运行gunicorn + nginx请求

我已经为我们的Django驱动的应用程序整合了一个集成服务器。 一些function仍然是实验性的,并导致过长的请求。 我现在的performance还不错,但我需要能够整合。 无论何时我们使用导致长时间请求的function,应用程序都会挂起(如预期的那样),然后在一分半钟后返回“502 – 错误的网关”。 应用程序的其余部分工作正常。 我检查了gunicorn日志,每当发生这种情况,我得到一条线 2012-01-20 17:30:13 [23128] [DEBUG] GET /results/ 2012-01-20 17:30:43 [23125] [ERROR] WORKER TIMEOUT (pid:23128) Traceback (most recent call last): File "/home/demo/python_envs/frontend/lib/python2.6/site-packages/gunicorn/app/base.py", line 111, in run os.setpgrp() OSError: [Errno 1] Operation not permitted 然而,这发生在实际的工人超时之前,我已经设置为10分钟,以确保。 这是运行gunicorn的暴发剧本的一部分。 description "…" start on runlevel [2345] stop on runlevel [!2345] #Send KILL after 5 […]

Nginx和PHP-FPM没有连接

我不断遇到像这样的错误, [02-Jun-2012 01:52:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 19 idle, and 49 total children [02-Jun-2012 01:52:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 19 idle, and 50 total children [02-Jun-2012 01:52:06] […]

使用Passenger时,使用Nginx的Apache和Rails有什么优点和缺点?

Passenger最近得到了对Nginx的支持,Apache作为Rails应用程序的Web服务器有什么优点和缺点呢?

为什么我的nginx别名不工作?

我试图设置一个别名,所以当有人访问/phpmyadmin/ ,nginx会从/home/phpmyadmin/而不是从通常的文档根目录中取出它。 但是,每次我拉起URL,它都会给我一个没有通过fastcgi拉的所有项目的404。 fastcgi似乎工作正常,而其余的不是。 strace告诉我,它试图从通常的文件根目录中拉出所有的东西,但我不明白为什么。 谁能提供一些见解? 这是我的configuration的相关部分: location ~ ^/phpmyadmin/(.+\.php)$ { include fcgi.conf; fastcgi_index index.php; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_param SCRIPT_FILENAME /home$fastcgi_script_name; } location /phpmyadmin { alias /home/phpmyadmin/; }

上传大于1MB的文件=连接重置

我前端使用nginx作为“代理caching”和后端Apache,我已经把我的PHP设置如下: error_log = /var/www/site1/php_error.log error_reporting = 22527 file_uploads = On log_errors = On max_execution_time = 0 max_file_uploads = 20 max_input_time = -1 memory_limit = 512M post_max_size = 0 upload_max_filesize = 1000M 有什么问题? 上传less于1MB的文件是成功的,但是比Chrome浏览器输出的更多: Error 101 (net::ERR_CONNECTION_RESET): The connection was reset. 我已经检查了错误日志文件,但是它不存在于目录中。 我也检查/var/log/httpd/error_log但没有上传相关的问题。 我不知道有什么可能导致这个问题,所以我伸出援助之手。 谢谢!

如何遵循Nginx中的HTTPredirect?

我有一个基于nginx的HTTP代理,我想处理其中的所有HTTPredirect,以便客户端只获取redirect链中的最后一个响应。 基本代码如下所示: location /proxy { rewrite ^/proxy/([^/]+) $1 break; proxy_pass http://$uri/; } 我试图遵循1级redirect是这样的: error_page 301 302 307 =200 @redir; …有这个命名的位置: location @redir { proxy_pass $proxy_location; } 只有没有$ proxy_locationvariables,我没有find一个方法来创build它。 它应该包含从上游收到的Location:头的值。 有什么想法吗?