Articles of nginx

强制WWW与清漆和nginx

我试图找出如何强制WWW在清漆只有一个领域。 我看到这个答案,以消除WWW,但我不知道如何翻译它来强制它。 编辑:澄清,我的nginxconfiguration工作正常。 直到我添加清漆之后,才发生这种情况。 我find了罪魁祸首,回答了我自己的问题。

需要帮助configurationnginx与2个不同的主机名称,支持通配符子域名

我的第一个服务器块是 server{ listen 80; server_name xxx.to; server_name *.xxx.to; root /data/xxx/public_html/; } 第二个是 server{ listen 80; server_name yyy.to; server_name *.yyy.to; root /data/yyy/public_html/; } 但是当我绑定一个CNAME链接subdomain.yyy.to其redirectsubdomian.xxx.to不subdomain.yyy.to

nginx错误映射

如何将nginx中的错误代码/页面映射到更多的描述性文件名? 例如, 我有一个像404-NotFound错误,我想轻松地将404错误代码映射到Nginx中。 我不想指定每个error_page映射,因为这将是乏味的。 它也会膨胀conf文件,因为它必须为每个服务器完成。 我已经有一个地图设置,但新的nginx,并不知道如何得到它一起工作。 (我所有的错误页面都以错误代码开始,所以实际上,我宁愿有一些方法可以自动find文件,因为每个错误代码只有一个文件。 例如,错误404被映射到文件404-NotFound.html,如果我不需要指定它,它会很好,但是它自动检测到。) 我也想支持多种语言…

定期地点与指定地点

我有一个使用Thin运行的Rails应用程序,我希望Nginx充当反向代理,将给定位置下的所有请求传递给Thin服务器。 从我读过的所有内容(这已经是相当多的了),似乎最stream行的解决scheme是有以下站点configuration文件: upstream thin { server 127.0.0.1:3000; } server { … location /thin { proxy_pass http://thin; } } 但是,在我的情况下,这个设置的问题是/thin部分传递给Thin。 我在其他地方读过,因为这个原因,最好使用一个命名的位置: server { … location @thin { proxy_pass http://thin; } } 但是,当我使用这个configuration时,检查/var/log/nginx/error.log我看到请求没有传递到瘦服务器(服务器位于IP地址192.168.1.15和客户端是192.168.1.105) : 2013/04/11 12:55:58 [error] 17988#0: *1 open() "/var/www/thin" failed (2: No such file or directory), client: 192.168.1.105, server: , request: "GET /thin HTTP/1.1", host: […]

我需要什么样的ssl证书来支持反向代理上托pipe的多个域的多个子域

我有一个nginx反向代理,有多个多域的子域。 有一些内容操作发生在我的服务器上,因此需要反向代理。 他们全部托pipe在一台服务器上,只有一个IP地址。 例如。 example.com blog.example.com another-example.com shop.another-example.com 这些网站中的每一个都在其他地方托pipe,并在必要时设置SSL。 我想知道的是我可以通过https提供所有这些域和子域,我需要什么样的SSL证书? 据我所知,我可以为每个父域使用通配域证书,或为每个完全限定域使用多域证书,但有没有更简单的解决scheme? (一个不会花费我的财富)如: 一个证书,将validation我的一个IP地址 我可以将浏览器凭据传递到目标服务器的一种方法 一种authentication为单一域名的方法“host.nginxproxy.com” 如果我没有正确解释我自己的道歉

Nginx,PHP-FPM和多个域

我是nginx和php-fpm的新手。 我的问题: 我需要创build两个php-fpmconfiguration文件还是只有一个? 可以两个nginx的configuration(不同的域名/应用程序)指向相同的PHP套接字? 如果是这样会导致会话冲突或任何其他问题? 下面有两个nginxconfiguration和一个php-fpmconfiguration。 如上所述,我应该有两个php-fpmconfiguration? php-fpmconfiguration: [appname1] listen = /var/www/apps/appname1/tmp/php.sock user = www-data group = www-data pm = dynamic pm.max_children = <%= node['php5-fpm']['max_children'] %> pm.start_servers = <%= node['php5-fpm']['start_servers'] %> pm.min_spare_servers = <%= node['php5-fpm']['min_spare_servers'] %> pm.max_spare_servers = <%= node['php5-fpm']['max_spare_servers'] %> pm.max_requests = 1000 pm.status_path = /php_status request_terminate_timeout = 0 request_slowlog_timeout = 0 slowlog = […]

运行Nginx时Apache被php-fpm使用?

我不知道是否有人可以帮助我为什么这个内存正在使用。 我使用Centos 6.3,Nginx,PHP和MySQL运行一个低端的内存盒,512MB RAM,但是当我运行一个ps aux并且使用了大量的RAM时,Apache就出现了。 apache 1166 0.0 3.7 78620 19500 ? S Apr19 0:01 php-fpm: pool w apache 1167 0.0 3.7 79076 19844 ? S Apr19 0:01 php-fpm: pool w apache 1168 0.0 3.5 78312 18732 ? S Apr19 0:01 php-fpm: pool w apache 1169 0.0 2.6 61744 13656 ? S Apr19 0:01 php-fpm: […]

configurationnginx将外部端口转发到同一个内部端口

我正在运行从本地主机监听端口20008和20009的TileMill。 我想只能通过端口80上的nginx访问20009(使用简单的身份validation)。 我想20008可以从外面“直接”访问。 server { listen 80; server_name localhost; location / { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:20009; auth_basic "Restricted"; auth_basic_user_file htpasswd; } } server { listen 20008; server_name localhost; location / { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:20008; } } 显而易见的问题是,nginx无法侦听端口20008 – 它已被TileMill使用。 Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:20008 failed (98: Address already in use) […]

如何在nginx位置块中设置一个PHP-FPMvariables?

出于某种原因,我们的网站有一个.jsphp文件需要交给PHP-FPM。 但是,访问将被拒绝,因为默认情况下,PHP-FPM只允许扩展.php 。 这可以通过将以下内容添加到php-fpm.conf来解决 security.limit_extensions = .php .jsphp 但是我只想为Nginxconfiguration中的特定服务器位置执行此操作,如下所示 location ~ (\.php|\.jsphp)$ { try_files $uri = 404; include /usr/local/etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9001; # 9000 for xdebug fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "error_log=/usr/local/var/log/our-website.local-error.log"; } 是否可以添加每个服务器位置的PHP-FPM设置security.limit_extensions ? 如果是这样,我该怎么做? 谢谢!

nginx只提供域的主目录

我已经build立了nginx,并在两个不同的领域(有点)工作。 但由于某种原因,nginx只能提供目录的索引文件,不pipe在地址栏中input什么内容。 例如。 example.com/about只显示example.com 这里是我目前的configuration,如果你们中的任何一个人/女孩都可以帮助我,那将不胜感激,谢谢! server { listen 80; server_name samayres.net www.samayres.net; index index.html index.php index.htm; access_log /home/sam/www/samayres.net/logs/access_logs.log; error_log /home/sam/www/samayres.net/logs/error_logs.log; root /home/sam/www/samayres.net; error_page 401 401.html; error_page 403 403.html; error_page 404 404.html; error_page 500 502 503 504 500.html; location / { try_files $uri $uri/ /index.php?$args; } # rewrite adminpanel to use https rewrite ^/adminpanel(.*)$ https://$host$uri permanent; […]