Articles of nginx

TXTlogging导致子域名无法parsing

我有我的nginx.conf中的以下条目,这允许我去http://somerandomstuff.domain.ie ,我的app_subdomain_handler应用程序然后处理,这工作正常。 upstream app_subdomain_handler { server 127.0.0.1:5001; keepalive 8; } server { listen 0.0.0.0:80; server_name *.domain.ie; location / { proxy_pass http://app_subdomain_handler/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; } } server { listen 443 ssl; server_name *.domain.ie; location / { proxy_pass http://app_subdomain_handler/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header […]

在我的生产环境中安装和configurationnginx

我知道这里有一些愚蠢的,但我似乎无法解决这个在我的情况。 我正在安装和configurationnginx,为我的VPS提供一个有用的,更快的服务器。 我正在使用Putty命令提示符。 我正在尝试为这个项目创build自己的结构。 为什么nginx.conf语法不行? 为什么这个nginx.conftesting不成功是我无法理解的。 谁能提供一些反馈? 我得到这个错误: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-enabled/default:18 nginx: configuration file /etc/nginx/nginx.conf test failed configuration细节如下: # You may add here your server { server_name 123.456.789.0; return 301 $scheme://example.com$request_uri; # } # statements for each of your virtual hosts to this file ### of Nginx configuration […]

无法从外部服务器访问nginx

在这里,我再次与nginx的另一个奇怪的错误。 我使用debian和nginx作为web服务器运行服务器。 一切正常,直到它突然停止接受来自服务器外部的连接。 我无法从任何浏览器访问网站(通过ERR_CONNECTION_TIMED_OUT ),我无法使用telnet连接到服务器IP,服务器IP和端口80或443 …但我可以通过端口22访问,所以SSH和FTP在工作中。 如果通过SSH我curl IP显示我的HTML的内容。 正如我所说,一切都在以前工作,突然之间,没有做任何改变的服务器。 它也运行nginx并没有显示任何错误。 我完全失去了诚实。 任何想法为什么发生这种情况,以及如何解决? 编辑: 这里是access.log 。 它不显示我尝试从任何浏览器访问网站的任何时间。 94.23.253.89 – – [19/Nov/2015:00:47:57 +0100] "GET / HTTP/1.1" 200 18 "-" "curl/7.38.0" 94.23.253.89 – – [19/Nov/2015:00:48:16 +0100] "GET / HTTP/1.1" 200 18 "-" "curl/7.38.0" 94.23.253.89 – – [19/Nov/2015:00:48:23 +0100] "GET / HTTP/1.1" 200 5194 "-" "curl/7.38.0" 这是netsat -ltnp的结果 tcp […]

与nginx服务器一起设置Node应用程序

我正在尝试设置一个新的节点,以及我以前的PHP应用程序。 脚本 php应用程序在www.xyz.com运行。 它使用nginx来提供。 节点应用程序通过端口8142上的NodeJs服务器提供服务。 我想在链接www.xyz.com/nodeApp上服务NodeJs应用程序 我试过了 我的方法是将所有在www.xyz/nodeApp上www.xyz/nodeApp的请求都代理到端口8142,节点服务器将在端口8142处接收请求。 我将以下代理conf添加到www.xyz.com的nginx文件。 location ~ ^/nodeApp(.*)$ { proxy_http_version 1.1; proxy_pass_request_body on; proxy_set_header Host $host; proxy_set_header Scheme $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8142$1$is_args$args; proxy_buffering off; } 结果 打到www.xyz.com/nodeApp/ ,一切正常。 节点服务器提取请求,并在www.xyz.com/nodeApp/app.js等链接中提供css和js文件。 但是(没有后面的斜线) 点击www.xyz.com/nodeApp ,它不起作用。 节点服务器提取请求并正确提供html页面,但是css和js文件在链接www.xyz.com/app.js等处提供。所以应用程序中断。 我错在哪里? 我的节点服务器文件 var express = require("express"); var app = express(); app.use(express.static(__dirname + '/build')); […]

如何查看nginx重写规则应用于请求的内容?

我试图debugging为什么一些重写规则不能在我的登台服务器上工作,即使他们在我的虚拟机上工作。 好像当我重新启动nginx时,它根本没有看到我的更改。 有没有办法,我可以看到实际加载的conf是在nginx中,还是logging什么重写规则正在应用到传入的请求?

Nginx – 在不同服务器上的子目录中运行网站

我有一个网站https://www.winni.in运行在后面的nginx的tomcat,我也有一个WordPress的博客,它有url https://www.winni.in/blog这两个位于同一台机器aws ec2 由于某种原因,我想WordPress的博客位于一个单独的ec2实例,也运行nginx。 但是我不想把url改成blog.winni.in这样的子域名,有没有办法做到这一点? 我可以在单独的ec2实例上运行博客,但继续使用url作为winni.in/blog ?

最佳做法是什么:在web服务级别或代理级别使用HTTPS?

现在我不得不部署几个Web应用程序,比如Jenkins或者jupyter 。 这些应用程序必须通过HTTPS提供。 我想知道是否最好在每个应用程序(侦听端口,SSL证书等)上configurationHTTPS,或者运行默认configuration,并使用像nginx这样的反向代理来强制HTTPS。 我觉得第二个解决scheme更实用,但是从安全的angular度来看,我可能错过了一些东西。

如何拒绝包含特定标题的请求,而不是来自nginx中列入白名单的IP?

我想双重保护使用自定义标头的应用程序来授权一些重要的视图。 由于这些调用应该只来自一些知名的IP,我想阻止包含这个自定义头的请求(如X-SuperAdminToken),而不是来自白名单IP。 就像是: if ($http_xsuperadmintoken) { allow 192.168.1.0/24; allow 10.1.2.3; deny all; } 但似乎我不允许在一个if块中放置一个allow指令: # nginx -t nginx: [emerg] "allow" directive is not allowed here in /etc/nginx/sites- enabled/default:44 我还没有find解决方法。

为什么nginx别名在.php文件上返回404?

这个configuration工作: location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } 但是,这会在每个.php文件上返回404(而.css / .txt工作正常): location /pma { alias /usr/share/phpmyadmin; index index.php index.html index.htm; location ~ ^/pma/(.+\.php)$ { alias /usr/share/phpmyadmin/$1; […]

转发SOAP请求

我遇到了以下情况。 客户端在端口80上提供soap服务。他们的客户端访问服务的准确性不得而知,但他们假设他们的脚本中有uris硬编码。 目前我们正在为我的客户开发一个新的网站,它将在当前的域名上运行。 肥皂服务将被移动到一个子域。 由于他们不想打扰他们的客户与肥皂服务的域更改,我被要求将所有肥皂请求转发到子域上的服务器。 我现在的问题是,这可以做,如何? 我正在Ubuntu 14.04上运行一个Nginxnetworking服务器。 我们能不能把这个端点https://www.domain.nl/services/soap转发到https://subdomain.domain.nl/services/soap,还是我们需要使用iptables呢? 在iptables的情况下,我们如何能够从常规的web请求中分离肥皂请求?