Articles of nginx

Nginx Thin.Sock找不到错误

3个文件簇(err.log,chat.yml,Nginx的chat.conf): err.log: 2015/03/19 15:05:50 [crit] 1535#0: *79 connect() to unix:/var/www/chat/public/tmp/sockets/thin.0.sock failed (2: No such file or directory) while connecting to upstream, client: 162.243.6.35, server: chat.stackin.money, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/chat/public/tmp/sockets/thin.0.sock:/", host: "chat.stackin.money" 2015/03/19 15:05:50 [crit] 1535#0: *79 connect() to unix:/var/www/chat/public/tmp/sockets/thin.1.sock failed (2: No such file or directory) while connecting to upstream, client: 162.243.6.35, server: […]

nginx – 在每个应用下从公共目录提供静态内容

我几乎所有nodejs应用程序中都有类似的项目结构和目录,我通过nginx转发代理。 结构如下: /var/srv -/app1 -/public -/css -/js -/img -/app2 -/public -/css -/js -/img -/app3 -/public …… 希望你明白了。 现在我已经硬编码服务静态文件代码在Nginx的每个项目提供位置和别名,但我想这样的事情: location /$app_var/public/(js or css or img or other static content) { 然后将其别名为 alias /var/srv/$app_var/public/(js or css or img or other static content) 以便它可以根据项目的目录提供静态内容,我不必手动指定每个项目的位置。 如果我没有更好地解释它,请做评论。 谢谢 :) 我目前的configuration: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root […]

nginxredirecthttp到https不工作

我正在尝试从http重新路由到https。 例如,您访问example.com,您将被自动redirect到https://example.com 。 我尝试使用这一个: server { listen 80; return 301 https://$host$request_uri; } 以及这一个: server { listen 80; server_name example.com; return 301 https://$server_name$request_uri; } 在这里find: 在Nginx,我怎么能重写所有http请求,同时维护子域? 但是,似乎对我来说都不是什么东西。 我留在example.com上。 任何人有一个想法?

将任何子域转发到单个服务器

有网站example.com 我怎样才能configurationNginx的区域文件,像test.example.com等每个子域将被转发到一台服务器。 问题是我不知道可能的子域名,所以我不能手动列出它们。

Nginx的:位置正则expression式不工作

我正在得到我的正则expression式的麻烦,不知道它是什么问题。 它是用orls/f而不是orls/f?p=4550来返回一个URi。 当我通过https://secure.toto02.com/orls/myservice/f?p=4550 我的conf文件在下面 location ~ "^/([a-zA-Z]+)/myservice/(.+)$" { error_log /var/log/nginx/error-server.log notice; rewrite_log on; #proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://192.168.3.45:8080/orls/$2; proxy_redirect http://192.168.3.45:8080/orls/ https://secure.toto02.com/$1/myservice/ ; } 谁能帮忙?

nginx – 正则expression式捕获多个位置

创build多个位置的正则expression式捕获。 树结构: /home/user/webapps/ ├── index.html <= content: root. ├── osqa │ ├── index.html <= content: osqa test A. │ ├── osqa <= django project │ │ ├── index.html <= content: osqa test B. │ │ └── osqa │ │ ├── settings.py │ │ └── wsgi.py │ ├── run │ └── static └── forum ├── index.html […]

nginxconfiguration – replace/重写页面上的所有死链接。 向uri添加前缀

我想为网页上的每个链接注入“项目名称”。 例如:链接和网站http:// localhost / osqa /正在工作,但是当我在osqa页面上时,所有链接都直接指向本地主机http:// localhost / account / signin / – 被破坏… 所以我想重写/redirect所有链接指向项目名称位置,如http:// localhost / osqa / account / signin / 有没有可能,如果是的话怎么做? 现在我正在学习重写和try_files。 这是我的项目树结构,项目名称是(osqa,forum,other_project,another_project): /home/user/webapps/ ├── osqa │ ├── osqa │ ├── media │ └── static ├── forum │ ├── forum │ ├── media │ └── static ├── other_project │ ├── other_project │ […]

nginx:为什么在一个域的SSLconfiguration启用其他的?

假设我有app1.domain.com和app2.domain.com ,以及它的基本configuration文件app1.conf和app2.conf ,在vhosts.d文件夹内。 SSLconfiguration文件应该包含应用程序的path和证书的path。 但是,为什么仅在app1( app1.ssl.conf )中添加SSLconfiguration文件app1.ssl.conf在app2上启用SSL? 我的意思是,我可以进入https://app2.domain.com ,从app1的SSLconfiguration中获取SSL密钥path。

nginx或haproxy或varnish多个IP地址,反向代理和手动故障转移

好吧,这就是我想要完成的一切。 返回地面我有多个IIS Web服务器,每个都运行多个Web站点,每个站点都有自己的IP地址。 每个IIS“网站”通过编程和主机头来运行数百个网站。 我想插入一个反向代理服务器,我有每个Web服务器。 这是我想要反向代理服务器接受给定IP地址(1.2.3.4)上的所有stream量,并将stream量传递给IIS站点(1.2.3.104) – 这可以在nginx或varnish中完成。 反向代理将有大约10个定义的监听IP地址(1.2.3.4 – 1.2.3.14),每个转发stream量到自己相应的IIS站点(1.2.3.104 – 1.2.3.114)。 它不是一个负载平衡,我们具体是路由IP到具体的IP。 我认为这是可能的nginx或清漆。 现在有趣的部分我想创build一个新的备份 IIS服务器,这将有网站,在这个例子中有IP地址1.2.3.204 – 1.2.3.214)。 我想手动故障转移到这个备份服务器的stream量。 我最终将configuration所有的IIS服务器使用这个备份服务器,我将用它来在我的Web服务器上运行更新,这就是为什么我只想用它作为手动故障切换服务器。 我知道我看到某处有一个“命令行”来故障转移到备份服务器,但是我找不到它是什么产品,但我认为它是nginx。 我不需要caching任何东西,因为我们在IIS中caching对象,这就是为什么我需要专门发送从1.2.3.4到1.2.3.104和1.2.3.5到1.2.3.105等的stream量

如何将multiplte node.js实例连接到单个域?

我有相同的IP几个node.js实例。 通过nginx反向代理在不同的域上运行的每个实例。 例如: map_hash_bucket_size 128; map $host $backend_servers { hostnames; default 127.0.0.1:3000; example.com 127.0.0.1:3001; example.net 127.0.0.1:3002; example.org 127.0.0.1:3003; } server { listen 1.2.3.4:80 default_server; server_name _; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-NginX-Proxy true; proxy_pass http://$backend_servers; # upstream here proxy_redirect off; } } 我想要将来自example.com的path前缀/foo所有stream量定向到127.0.0.1:3002并从服务器中删除example.net 。 到example.net/bar旧链接应该redirect到状态301永久移动到example.com/foo/bar 。 这是我的最终目标: […]