Articles of nginx

从nginx连接到redis2

我在nginx中configuration一个位置如下: location /download { secure_link $arg_key,$arg_expires; secure_link_md5 "$secure_link_expires$uri$remote_addr download"; if ($secure_link = "") { return 403; } if ($secure_link = "0") { return 410; } set_unescape_uri $key $arg_key; set_unescape_uri $value $arg_expires; redis2_query setnx $key $value; redis2_pass 127.0.0.1:6379; proxy_pass http://172.16.10.134/$uri; proxy_set_header Host $host; proxy_cache $STATIC; proxy_cache_valid 200 1d; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 […]

nginx proxy_pass被忽略

我有一个作为代理服务器的Nginx服务器。 我还有3个不同的NodeJS Express服务器在端口8080,9090和8888上运行(所有端口均正常工作)。 服务器8080和9090执行相同的APP。 8888上的服务器当POST请求被转发时,应该返回“POSTING”。 GET和POST路由都为服务器8888正确设置,如果直接用CURL请求调用它们,我会得到正确的响应: import Express from 'express'; import BodyParser from 'body-parser'; // Initialise server const server = Express(); // for parsing application/json server.use(BodyParser.json()); // Setting port server.set('port', 8888); server.post('/', function(request, response) { console.log('POSTING'); response.send('POSTING'); }); server.get('/', function(request, response) { console.log('GETTING'); response.send('GETTING'); }); console.log(`Starting server on port ${server.get('port')}`) server.listen(server.get('port')); 我的Nginxconfiguration如下: upstream amit4got { […]

带有dynamic端口转发的Nginx反向代理

我在Nginx上设置了一个反向代理。 我需要它听多个端口。 然后我想要在后端服务器上find完全相同的端口。 像这样: http:// frontendserver:9000 – > http:// backendserver:9000 。 这是我认为会工作 ## server configuration server { listen 9000 ; listen 9001 ; listen 9002 ; listen 9003 ; listen 9004 ; listen 9005 ; listen 9006 ; listen 9007 ; listen 9008 ; listen 9009 ; server_name frontendserver; if ($http_x_forwarded_proto = '') { set […]

在同一台服务器上设置nginx的owncloud和其他服务?

现在我有nginx使用3个服务:1. my.example.com/~ignacio上的我的网页,my.example.com/rstudio上的Rstudio服务器,以及my.example.com/shiny上的Shiny服务器。 这是我的configuration文件现在: # Redirect all traffic from port 80 to SSL port server { listen 80; return 301 https://$host$request_uri; } # Set reverse proxy to port 443 server { listen 443 ssl; server_name my.example.com; ssl_certificate /etc/letsencrypt/live/my.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/my.example.com/privkey.pem; ssl_protocols TLSv1.2; ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY13$ ssl_prefer_server_ciphers on; index index.php index.html index.htm; # PHP in home directory location […]

如何区分nginx代理上的内部错误代码502和上游返回的http_502

我们使用nginx作为http代理服务器。以下configuration: location / { proxy_pass_header Server; proxy_pass $scheme://$http_host$request_uri; } 当url代理从真正的http主机返回错误代码502时,我们的客户端从nginx接收错误代码502。 当发生错误如dns错误或连接错误时,我们的客户端也收到错误代码502。 如何区分内部错误代码502和上游返回的http_502在我们的nginx代理。

尝试在端口80上运行时,在OSX上的nginx沮丧

由于某种原因,这不起作用: server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } … } 我有 Failed to connect … port 80: Connection refused (我testing了nginx正在运行,端口80被它占用) 然后,我改变了听指令: listen [::]:80; 它的工作… 但是我有其他服务器的问题,例如: server { #listen 80; listen [::]:80; server_name project.dev; location / { try_files $uri $uri.html $uri/index.html; root /Users/david/project; index index.html index.htm; } } […]

Nginx:502错误的网关错误(111:连接被拒绝)到uWSGI套接字,同时运行Django

我正在使用Nginx,uWSGI,Django和Postgresql堆栈构build应用程序。 该应用程序在Nginx和uWSGI之间使用Unix套接字。 在套接字上的文件权限是775.但我仍然得到这个权限错误: [error] 6978#0: *6725 connect() to unix:/path/to/socket failed (111: Connection refused) while connecting to upstream, client: 54.250.253.225, server: example.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/path/to/socket:", host: "example.com" Nginxconfiguration # uWSGI upstream upstream app{ server unix:/path/to/socket; } # redirect www to non-www server{ listen 80; server_name www.example.com; return 301 http://example.com$request_uri; } # configuration of […]

502错误的网关错误 – 退出信号11

我在两个不同的服务器上有一个特定的Magento商店的问题。 问题是,当我保存pipe理面板,我得到一个502错误。 这些值实际上保存到数据库,因为按下浏览器加载设置了新值的pipe理页面。 但是,保存后页面将始终为502,而不是刷新,手动按下是继续工作的唯一方法。 日志文件显示如下: /var/log/php5-fpm.log exited on signal 11 (SIGSEGV – core dumped) after 3.555010 seconds from start /var/log/nginx/website_dev_error.log [error] 38501#0: *625 recv() failed (104: Connection reset by peer) while reading response header from upstream 池文件variables [website.dev] listen = /var/run/php5-fpm.website.dev.sock user = www-data group = www-data listen.owner = www-data listen.group = www-data listen.mode = […]

任何版本的ModSecurity都可以与最新版本的Nginx一起使用?

我正在构buildNginx和ModSecurity,以便使用OWASP核心规则集项目 。 根据modsecurity下载页面,最新版本的modsecurity(2.9.1)在与Nginx一起使用时并不稳定。 这与我的经验是一致的(在Nginx 1.8.x或1.9.x上不能正常工作)。 我也尝试过ModSecurity的nginx_refactoring分支,但是这也是没有function的,而且在近两年里还没有看到提交。 有一个新版本的modsecurity即将上线(libmodsecurity),但还没有准备好,也没有任何指示什么时候可以准备好。 ModSecurity和支持的Nginx版本是否有任何组合?

设置端口443 ssl; 加载不同的服务器目录

运行Nginx + Centos 7.2 + WordPress 我正在为我的域安装SSL,并且当我在我的sererconfiguration中设置端口来listen 443 ssl; 当我访问域时,它会提示我“Welcome to nginx” 但是,如果我改回来listen 80; 它会显示我的网站。 这是我的服务器域configuration: server{ listen 443 ssl; server_name domain.com www.domain.com; root /var/www/data/domain.com/public_html/; index index.php index.html index.htm; client_max_body_size 500M; ssl on; ssl_certificate /etc/nginx/ssl/ssl-bundle.crt; ssl_certificate_key /etc/nginx/ssl/domain.key; ssl_prefer_server_ciphers on; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 […]