Articles of nginx

Nginx:在位置使用$ http_host

我在nginxconfiguration中有很多服务器别名: server { listen 80; server_name example.com site1.example.com site2.example.com site3.example.com … 如何我可以控制robots.txt文件的位置别名的具体文件夹,例如我的意思是: location ^~ $http_host/robots.txt { alias /home/web/public_html/static/$http_host/robots.txt; } 以上build设不能工作。

configurationNGINX:如何处理上游本身的500错误,而Nginx处理其他5xx错误

我们有一个NGINX反向代理(集群),有45个上游(22个域名,20个子域名,11个应用程序)。 我们的一些项目为全球的一些用户提供apis。 我们的开发人员为特殊情况devise了特殊的自定义500响应,并希望只显示上游tomcat_api的消息。 他们想要服务500页,并处理不在NGINX上的tomcat_api上游成员的exception。 但是我们想要处理NGINX上所有其他的5xx错误。 因为我现在不能成功需要一个手。 这里是服务器configuration如下,请你帮忙? 服务器{ server_name api.hotcoldwarm.com; 位置 / { add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection“1; mode = block”; add_header x-redirect-uri hotcoldwarm; add_header Strict-Transport-Security“max-age = 31536000; includeSubdomains; always”; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header主机$主机; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_pass http:// tomcat_api; proxy_next_upstream错误超时http_502 http_503 http_504 http_404; proxy_connect_timeout 1; } 听80; 听443 ssl; […]

Nginx阻止Windows Server 2012 r2上的wowza

我有一个运行在Windows Server 2012 r2和wowzastream引擎4.6.0的apache(xampp包的一部分) 一切正常,我可以用同一台服务器上的jwplayer播放器播放video。 从网页访问时该页面工作。 我们正在寻求提高服务的请求量,现在它是每秒4页可悲。 与Nginx和fastcgicaching它承诺更稳定和页面每秒服务。 我build立了Nginx来运行mysql和php fastcgi的站点。 Nginx的安装被设置为在不同的端口9011上使用另一个mysql数据库,所以apache和nginx是独立的系统。 这个问题开始,当我尝试播放任何video,从Apachestream没有运行时从wowza。 在video开始缓冲之前需要一分钟左右的时间(当apache在1秒钟内运行时)。 当我closuresapache,并开始nginx的video播放器加载,当我点击播放它只是盘旋,不播放甚至不缓冲。 我怀疑这是因为nginx阻塞了什么? rtmp:1935或http或smil文件都不能在启用nginx的情况下工作,但是如果直接访问,我可以下载smil文件。 Xampp是默认安装的,没有关于wowza或ports的额外设置。 Wowza是默认安装的,一切都是默认的。 那么为什么在没有运行Apache的情况下stream文件需要更长的时间,以及为什么当nginx运行时它完全中断? 我如何让wowza与nginx一起工作?

NGINX AUTH PAM只允许子网

这很奇怪 它正在工作。 今天不行 如果加上添加满足,我的门都是开放的,如果我否认所有,它否认一切。 我怎样才能select允许的和不允许的? satisfy any; allow 192.168.78.0/24; allow 192.168.81.0/24; allow 2001:470:1f1b:5b3::/64; allow 2001:470:1f1b:5b5::/64; allow 172.19.13.0/24; allow 192.168.17.0/24; allow 192.168.18.0/24; #deny all; auth_pam "Restricted"; auth_pam_service_name "nginx";

将所有未处理的请求redirect到/在nginx中

我必须设置一个有NodeJS后端和一个React webapp前端的服务器。 Nginx和Node应用程序在单独的docker容器中运行,我想这样做: 所有前缀为/api请求都将重新路由到NodeJS应用程序 所有的文件请求将由nginx(html,css,js等)提供,404如果找不到。 其他每个请求都应该被redirect到/ (即前端应用程序) 最后一条规则是需要的,因为这些路由在ReactJS内部处理,但是如果有人重新加载页面,它将得到一个404,因为nginx会尝试加载profile文件。 这是我目前的configuration server { listen 80; root /var/www/myapp; error_page 404 /404.html; location /api { 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 X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_pass http://app:61337; } location ~* \.(js|css|gif|jpg|jpeg|map|png|svg|ttf|eot|woff|woff2|json|ico)$ { root /var/www/myapp; } location / […]

NGinxconfiguration多个自定义登陆页面

我正在做一个nginx设置,让我主持几个登陆页面,应该有谷歌友好的url。 基本上主站点连接到一个应用程序服务器和几个子站点与静态html文件应承载nginx。 我的url架构如下所示: https://example.com/ -> application server (proxy pass – this works already) https://example.com/l/* -> landing page subsite structure root https://example.com/l/projectA/my-google-friendly-url.html -> specific subsite document https://example.com/l/projectA/my-other-google-friendly-url -> other specific subsite document without ".html" extension that maps to a file called page2.html on the filesystem of the subsite https://example.com/l/projectA -> should redirect to https://example.com/l/projectA/my-google-friendly-url.html https://example.com/l/projectA/ -> […]

如何使用nginx子filterreplacejs文件variables

我想在运行时使用NGINX子filterreplacejs文件中的IP。 我已经添加了sub_filter的位置,但它不工作。 我的nginx.config文件是 location ~ \.js { sub_filter "###IP###" "$remote_addr"; sub_filter_once off; sub_filter_types application/x-javascript; add_header Content-Type application/x-javascript; } 而我的JS代码是 var IP = "###IP###"; console.log(IP); 但IP在这样的控制台中打印###IP### 我的代码中有什么问题?

使用Nginx将子域连接到tomcat7 war实例

我需要在Ubuntu上使用Nginx webserver连接一个war实例(war-demo.war)和clojure2.msms.com 。 这就是我所做的。 1.设置nginx / tomcat 在/etc/nginx/sites-enabled ,我设置了tomcat.msms.com连接到tomcat7。 Tomcat7与apt-get一起安装( https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get )。 我也检查/etc/init.d/tomcat7是否正确安装。 # the IP(s) on which your node server is running. I chose port 3000. upstream tomcat { server 127.0.0.1:8008; keepalive 8; } # the nginx server instance server { listen 0.0.0.0:80; server_name tomcat.msms.com; access_log /var/log/nginx/access_tomcat.log; error_log /var/log/nginx/error_tomcat.log; location / { proxy_set_header X-Real-IP […]

Nginx转发请求到URL

我试图转发一个http请求到服务器在请求的url中指定,但我总是得到一个404结果。 这是我的configuration: worker_processes 2; daemon off; error_log /var/log/nginx.error_log info; events { worker_connections 1000; # use [ kqueue | epoll | /dev/poll | select | poll ]; use epoll; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$gzip_ratio"'; log_format download '$remote_addr – $remote_user […]

NextCloud无限redirectlogin

login到NextCloud后,我得到了无尽的redirect,只是不断得到我的访问日志中的下面: [08/Jul/2017:00:18:49 +0100] "GET /login?redirect_url=/apps/files/ HTTP/1.1" 200 10760 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36" 我使用Nginx和PHP-FPM 7运行CentOS 7 Nextcloud Nginx Conf.d文件: upstream examplecombackend { server unix:/var/run/php-fcgi-examplecom.sock; } server { listen 80; server_name example.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name example.com; access_log /var/www/vhosts/example.com/access.log; error_log /var/www/vhosts/example.com/error.log; ssl_certificate […]