Articles of nginx

Nginx和Gunicorn'err_conn_refused',但是nginx没有logging错误

我一直在Django Cookie Cutter的地方项目中玩耍,想把它作为一个半生产阶段环境放在我的DO Droplet上。 服务器设置Nginx的反向代理到各种项目,一些服务与Gunicorn,一个裸瓶,一个与uWSGI。 每个项目都有自己的virtualenv。 在部署这个项目并进行设置时,我有以下一系列的错误。 Nginx的conf如下(这反映在这个液滴上的其他网站): server { server_name test.myserver.com; access_log off; location /static/ { alias /var/www/myproject/static/; } location / { proxy_pass http://127.0.0.1:8085; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } 在第一个例子中,重置nginx并且不设置Gunicorn后,这个“工作”/做我所期望的:抛出一个502错误的网关错误和nginx日志注意: 2016/02/25 11:27:25 [error] 21217#0: *275 connect() failed (111: […]

反向代理Nginx,但cookies不通过WPpipe理员

我反向代理一个博客。 它在Apache下的子域blog.example.com上托pipe。 在Nginx中,我在服务器块中有以下configuration。 除了WPpipe理面板的cookie外,其他的工作都没有通过,所以我无法login。 我应该添加什么? location /blog/ { proxy_set_header X-Original-Host $host; proxy_set_header X-Is-Reverse-Proxy "true"; proxy_pass_header Set-Cookie; proxy_cookie_path / /blog/; proxy_pass http://blog.example.com/; } 谢谢!

NGINX:检查SSL(HTTPS)是否可用,如果不可用,则redirect到HTTP

目前的configuration是: server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl default_server; listen [::]:443 ssl default_server; listen 192.168.0.5:80 default_server; listen 192.168.0.5:443 ssl default_server; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_certificate /usr/share/nginx/default/ssl/default.crt; ssl_certificate_key /usr/share/nginx/default/ssl/default.key; server_name _; root /usr/share/nginx/default/www/; index index.php index.html; error_log /usr/share/nginx/default/log/error.log; access_log /usr/share/nginx/default/log/access.log combined; error_page 404 /404.html; error_page 403 /403.html; error_page 500 502 503 504 […]

Nginx的 – 如何检查一个位置的传入请求是否包含一组头文件?

我是服务器的新手。 最近我用Nginxconfiguration了一台服务器,并发现所有的工作正常。 现在我需要检查包含所有自定义标题的位置的请求。 我只需要检查标题名称,不必担心值。 我已经尝试过使用map指令,但似乎我需要为每个标题(将下面的代码粘贴)编写它。 map $http_custom_header $headerfound { default "access-denied"; Test "access-granted"; } 有什么方法可以一次捕获所有的头文件,并检查一组头文件名吗?

旧的URL到使用nginx的新的URL

我需要: 用新的search引擎优化友好的urlreplace旧的SEO不友好的url 如replace http://../products/?type=genre.main.key&key=DAN&title=Dance&page=1 同 http://../genres/dance?key=DAN&pg=1 并更换 http://../products/?type=genre.key&key=HOU&title=House&page=1 有: http://../genres/dance/house?key=HOU&pg=1 执行: 做映射客户端(angular)。 我想这将是相当复杂的 在nginxconfiguration中进行映射。 创build永久redirect(301)所有从旧到新(使用正则expression式) 创build一个服务于旧的代理服务器,并使用代理服务器来将新旧路由 第二种方法(我认为)确保search引擎友好的url被索引(2a),新的url被映射到代理服务器提供的旧url上。 上述方法(在2下列出)是否有效? 这是一个适当的策略? (这是之前我想尝试做这个工作,因为我几乎没有经验的nginxconfiguration,所以这将是一个艰巨的任务) 谢谢你的build议。 问候,德克斯特

Laravel的子目录 – Nginx和fastcgiconfiguration

我试图在我的nginx服务器hhvm上设置各种设备的应用程序,但经过大量的研究和许多尝试都无法成功。 有人可以帮我吗? 这是我目前的设置: server { listen 80; server_name 178.13.1.230; root /home/callcenter/public_html/gateway; location / { index index.html index.php; } location /crm { root /home/callcenter/public_html/gateway/crm/public; #rewrite ^/crm/(.*)$ /$1 break; index index.php index.html; try_files $uri $uri/ /index.php$is_args$args /index.php?$query_string; } location ~ /crm/.+\.php$ { root /home/callcenter/public_html/gateway/crm/public; #rewrite ^/crm/(.*)$ /$1 break; include /etc/nginx/fastcgi.conf; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include /etc/nginx/hhvm; […]

Nginx重写删除.php文件没有效果,只能redirect到主页

我试图重写从我的url中删除.php,但迄今没有运气。 这是我到目前为止,然后我的结果下面的这个configuration。 location ~ \.php$ { try_files $uri/ @extensionless-php; include fastcgi_params; fastcgi_pass hhvm; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache ASPS; fastcgi_cache_valid 200 60m; } location @extensionless-php { rewrite ^(.*)$ /$1.php last; } 这导致: example.com/page1.php转到example.com/page1.php并正确渲染example.com/page1渲染index.php example.com/page1/渲染index.php 有没有人遇到过这个? 这似乎是一个非常普遍的事情,但我有几个小时的麻烦,并无休止地在网上search。 谢谢你的帮助!

Nginx服务于node.js中的2个幽灵博客

我正在尝试使用nginxconfiguration运行Amazon linux的Amazon EC2实例,以在node.js中提供两个不同的ghost博客。 我的理解是,networkingstream量击中了ec2实例的公共IP,nginx正在侦听端口80,nginx的configuration文件反向代理每个域到每个博客的index.js文件正在侦听的端口。 我永远使用生产环境中运行两个index.js文件,但是当我开始两个域(domain1.com&domain2.com)显示相同的内容。 这似乎是开始第二个index.js覆盖/redirect到单个幽灵博客的stream量。 也许有些configuration可能有帮助: 主文件夹 ls ~ domain2.com node domain1.com Config.js for domain1.com cat ~/domain1.com/config.js production: { url: 'http://www.domain1.com/', mail: {}, database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') }, debug: false }, server: { host: '127.0.0.1', port: '2368' } }, Config.js for domain2.com cat ~/domain2.com/config.js production: { url: 'http://domain2.com/', mail: […]

蓝色/绿色testing与nginx +独angular兽的轨道

我正在使用Unicorn作为我的Web应用程序前面的应用程序服务器。 我希望通过同时运行两个版本的站点来进行蓝/绿色testing。 问题是根path是从一个版本的网站到另一个不同。 有没有办法做到这一点? 这是我的configuration。 现在它不起作用,因为当第二台服务器出现循环时,文件被破坏,因为它们不在根path。 upstream unicorn { server unix:/tmp/unicorn.main.sock fail_timeout=0; server unix:/tmp/unicorn.main_staging.sock fail_timeout=0; } server { listen 80; server_name mysite.com; root /var/www/sites/main/current/public; try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass https://unicorn; } location ~ ^/assets/ { expires 1y; add_header Cache-Control public; add_header ETag ""; break; […]

nginx子域名和DNS太多的redirect

我刚刚安装了nginx,并将其设置为通过apache安装。 事实上,我的规则是: server { listen 80; server_name example.com; location / { proxy_set_header X-Readl-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://example.com:8080; } location ~ /\.ht { deny all; } } 我想通过以下方式configuration一个子域名: server { listen 80; server_name sub.example.com; location / { proxy_pass http://example.com:8080/sub; } location ~/\.ht { deny all; } } 像这样configuration我的DNS: NAME | TYPE […]