Articles of nginx

我不得不重新启动uwsgi进程

我正在使用uwsgi和nginx的组合来服务我的烧瓶应用程序。 发生什么事是几个小时后(在非常低的负载下,<几百个请求),请求超时,直到我重新启动uwsgi进程,事情再次工作相同的时间。 这里是nginx的conf: server { listen 3001; server_name localhost; charset utf-8; client_max_body_size 75M; location / { try_files $uri @myapp; } location @myapp { include uwsgi_params; uwsgi_pass unix:/my/dir/uwsgi.sock; } } 我的uwsgi.ini: [uwsgi] #application's base folder base = /my/dir #python module to import app = app module = %(app) home = %(base)/venv pythonpath = %(base) #socket file's […]

nginx前端将HTTPS转发到HTTP,没有有效的证书

经过一番研究,我怀疑答案可能不会,不过我会问的。 情况是有NGINX前端作为apache后端的反向代理。 我的问题是 是否有可能转发/redirect/ …一个HTTPS的请求到一个正常的HTTP请求? EG: https ://foobar.com前端请求是否可以将请求转发/redirect到http://foobar.com而无需浏览器投诉,需要证书或SSL进程在手之前完成?

Nginx无法访问centospath

对不起,相当混乱的标题,我想了解这个错误。 我有一个php文件,在site.com/src/app/index.php这样的文件夹中,这个site.com文件夹放在/var/www/html/中,运行在CentOs 6.5中,运行Nginx和PHP-FPM。 所以,问题是,每当我使用任何path函数和常量像__DIR__ , getcwd() , index.php里面的realpath() ,我期望完整的path是 /var/www/html/site.com/src/app/但只有site.com/src/app/被返回。 这就好像那个php / nginx不知道var/www/html/文件夹。 我的事件去了app/目录,并能够使用sudo pwd得到完整的path,但由于某种原因,PHP不读它。 我想知道为什么会发生这种情况,以及如何解决这个问题?

错误代码:nginx ubuntu服务器上的ssl_error_rx_record_too_long

我有一个网站是完全运行在一些旧的Ubuntu服务器上的Apache,也有它的HTTPS。 但现在由于某些原因,我需要移动到不同的(高configuration新的Ubuntu服务器)服务器,并尝试使用Nginx服务我的网站,所以安装nginx( nginx/1.4.6 (Ubuntu) )。 以下是我的nginx.conf文件设置 server { listen 8005; location / { proxy_pass http://127.0.0.1:8001; } location /static/ { alias /root/apps/project/static/; } location /media/ { alias /root/apps/media/; } } # Https Server server { listen 443; location / { # proxy_set_header Host $host; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header X-Forwarded-Protocol $scheme; # proxy_set_header X-Url-Scheme $scheme; […]

NginX多个域名不能正常工作

在我的DigitalOcean液滴中,我正尝试使用我的NginX在同一个液滴上托pipe多个网站。 我可以使用或不使用default_server标记访问test.domain1.com和domain1.com 。 但是,访问domain2.com只是在浏览器中显示domain1.com (带有default_server标记的服务器块)的内容,而不会将 url转发到domain1.com 。 我检查了我的configuration错字,但找不到一个。 其次,access.log和error.log都没有任何问题。 我的液滴的主机名是domain1.com。 我已经创build了2个DNS条目 :1个用于domain1.com,另一个用于domain2.com。 两者都具有相同的A和CNAMElogging。 @ A ip.add.re.ss www CNAME @ * CNAME @ 我的configuration是: /etc/nginx/nginx.conf: http://pastebin.com/AWf5EM66 /etc/nginx/global/wordpress.conf: http://pastebin.com/Uc9KSqhh /etc/nginx/global/restrictions.conf: http://pastebin.com/cLfMv6jC /etc/nginx/sites-available/sites.conf: server { listen 80; listen [::]:80; root /usr/share/nginx/html/domain1_test; index index.php index.html index.htm; server_name test.domain1.com; include global/restrictions.conf; include global/wordpress.conf; } server { listen 80; listen [::]:80; […]

用php5-fpm设置nginx(源码build立)

所以对于nginx来说是新的。 在Ubuntu上,我使用“sudo apt-get install nginx”安装了nginx,然后安装了php5-fpm sudo apt get install php5-fpm 。 我遵循以下步骤: https : //www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04,并得到了nginx工作罚款与php5-fpm 。 这是从我的nginxconfiguration文件启用fastCGI代理的相关部分。 location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 这工作完美,PHP文件运行如何,他们假设。 然后我下载了nginx-1.7.3.tar.gz,如果从源代码build立: –configure –prefix=/usr/local/nginx-1.7.3 make sudo make install 所以现在我会有两个安装nginx。 第一个使用apt-get install nginx ,这个是从源码build立的。 我可以以不同的方式运行每一个sudo service nginx start运行apt-get install version , sudo /usr/local/nginx-1.7.3/sbin/nginx运行从源代码构build的版本。 要启用“从源代码构build”的fastCGI代理,我认为它与第一次安装nginx相同,因此nginx.conf文件的快速cgi代理位置块与第一个相同。 但 […]

nginx:忽略使用别名的情况

我有很多静态文件,其名称遵循以下模式: sku_(no)_1.jpg,sku_(no)_2.jpg,sku_(no)_3.jpg … 哪里(不)是6位数字。 因为有这么多的,我必须把它们放到不同的目录,并使用alias指令redirect请求,如: location ~* (sku_\d+(\d)(\d)(\d)_\d+)\.(jpg|png|jpeg|gif)$ { alias /path_to_directory/$4/$3/$2/$1.$5; } 现在困难的部分是,有时候,请求会带有大写字母,例如请求文件sku_101138_1.JPG / path_to_directory / 8/3/1 / sku_101138_1。 JPG 然而,实际的文件存储为 / path_to_directory / 8/3/1 / sku_101138_1。 JPG 这会导致404 not found 那么如何告诉nginx在使用alias指令时忽略大小写呢?

移动WordPress的文件到不同的位置后,Nginx的403错误

我有一个使用fastcgi的Rails应用程序内的Wordpress工作。 现在,我正在移动所有东西,以便在/生产中访问它。 我移动了wordpress文件并将nginx位置块从/ wptest更新为/ blog。 但是,我突然得到一个403错误。 我相信我的文件权限是正确的 – drwxrwxr-x所有文件夹和-rw-rw-r–文件。 欣赏任何build议。 这是我的nginxconfiguration: server { listen 80; server_name [private]; root [private]; index index.html index.htm index.php; try_files $uri/index.html $uri/index.php $uri; if (-f $request_filename) { break; } location / { rails_env production; passenger_enabled on; rails_spawn_method smart; } location /blog { index index.php; try_files $uri $uri/ $uri/index.php; location ~ \.php$ […]

Nginx始终提供相同的响应

对于一个即将上线的网站,我们经常在我们的网站根目录中有一个静态的index.html 。 该文件包含所有样式和图像内联,所以没有其他请求加载该页面。 现在,我使用这个configuration: # Temporary placeholder server { server_name .domain.com; root /var/www/domain/production/public; index index.html; charset UTF-8; } # Production server { server_name test.domain.com; root /var/www/domain/production/public; charset UTF-8; gzip_types text/plain application/xml text/css text/js image/svg+xml text/xml application/x-javascript text/javascript application/json application/xml+rss; location /assets/images { default_type image/jpeg; expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } […]

House Nginx在像htaccess文件这样的项目文件夹中重写规则

Nginx有没有像htaccess文件一样在项目文件夹内存放重写规则的方法? 我一直在/ etc / nginx / sites-available /里面设置我的规则 configuration文件。 我想跟踪我的Git仓库中的这些规则,以便在多个stream浪环境中使用,那么在项目www目录中有一个子configuration文件的方式? 我会使用标准的nginx包括? server { include /usr/share/nginx/html/???/rewrites.conf; … } 这是不好的做法(这只是为了开发环境)?