Articles of nginx

访问docker实例 – 最佳实践

从外部访问Docker实例的最佳实践是什么? 我打算部署几个docker实例(node.js,php,mysql),全部打包在一个或通过容器之间的docker链接。 可以在主机上控制每个Docker实例的端口,但是从外部访问这些实例的最佳做法应该是什么。 我宁愿只有子域,并摆脱实例的转发端口。 例如 : user@server:~/sandbox/docker-nginx$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3fc7c57ed66c docker-wordpress-nginx:latest /bin/bash /start.sh 3 days ago Up 3 days 0.0.0.0:49153->80/tcp evil_poincare 预期行为:请求wordpress.domain.com通过端口49153访问该docker实例内的wordpress,但浏览器不会使用该端口重写Location。 我看了一下/尝试了几种方法,但没有给我的function: 有线路由.json文件 在主机中使用nginx 反向代理 ,但仍然在redirect的url中有端口 skydock听起来不错,但没有多主机支持 pipe道工程看起来也不错,但免责声明警告我们很快应该由docker工程师提供。 对这个问题的任何想法,以及对最佳做法的任何build议将不胜感激,也许我只是失去了一些东西。

在一个端口上托pipe多个Nodejs应用程序

我试图运行多个nodejs应用程序(使用快速框架)所有服务在同一个外部端口(80),但每个子目录下。 比如我想… NodeJsApplication1在http://www.mydomain.com/NodeJsApplication1上可用 NodeJsApplication2在http://www.mydomain.com/NodeJsApplication2上可用 等等 我曾尝试使用Nginx作为代理类似于以下的configuration文件。 server { listen 80; server_name www.mydomain.com; location / { root /var/www/html; index index.html index.htm; } location /NodeJsApplication1/ { proxy_pass http://0.0.0.0:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; rewrite /NodeJsApplication1/(.*) /$1 break; } location /NodeJsApplication2/ { proxy_pass http://0.0.0.0:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; rewrite […]

安装GitLab后,“gitlab-shell自检失败”

所以我安装了GitLab和nginx,现在我在访问它的时候出现了502 Bad Gateway错误。 我通过检查sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ,发现我有一个错误,读取: Check GitLab API access: FAILED. code: 502 gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /home/git/gitlab-shell/config.yml Please fix the error above and rerun the checks.

覆盖代理的不正确的Content-Type

我有一个所有types的文件(css / js / jpg / png …)的起源,但出于保护的原因,它会为所有文件返回不正确的Conent-Type。 我想代理该来源并提供这些文件。 有什么办法让Nginx使用proxy_passreplace正确的Content-Type头?

PHP文件不能被nginx中的fastcgiparsing

我新的nginx我的服务器块是 server { listen 25552; server_name *.example.com; root /usr/share/myPackage; rewrite ^/$ /index.php permanent; location ~ ((\.php$)|(^/(status)$)) { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } access_log /var/log/nginx/console-access.log; } 使用浏览器即时获得状态200,而打我的url – www.example.com:25552/index.php和其他的PHP文件相同的状态,但没有在页面中显示。 虽然我尝试更改url,我能够在我的浏览器上获取我的html,js和图像文件。 我认为是我的PHP文件没有得到parsing请帮助我…. 🙂

nginx – 为子目录指定不同的索引文件名

我想在我的网站的根目录索引文件是index.html但在一个子目录/foo我希望它是bar.html 即 /index.html /foo/bar.html 另外我想请求/foo或/foo/或/foo/:anything要parsing到bar.html /foo/:anything 为什么我的位置阻止/ foo工作? 如何为/ foo指定位置块? 这是服务器定义: server { listen 80; server_name domain.tld; port_in_redirect off; location / { # ssl is terminated at our load bal if ($http_x_forwarded_proto != 'https') { rewrite ^ https://$host$request_uri? permanent; } root /usr/share/nginx/mysite/public; index index.html; add_header Cache-Control "public max-age=600"; add_header "X-UA-Compatible" "IE=Edge,chrome=1"; charset UTF-8; } # […]

我如何使用Nginx服务器提供多个静态内容?

我尝试Nginx是新手,因此这个问题可能很愚蠢。 需求: 一个对Nginx服务器的HTTP调用如何检索多个静态内容? 例如: http : //localhost.com : 80/data/test应该检索文件'A','B',…'Z'。 另外,我们可以使用Nginx实现URL分页。 http://localhost.com:80/data?index=100取100个文件。

Nginx反向代理不会加载HTTPS站点

今天是我第一次使用Nginx。 通过遵循一些指南,我将其设置为专用的反向代理。 这就是我想重新创build – http://www.integratedwebsystems.com/wp-content/uploads/2010/06/reverse_proxy.jpg 我有端口80工作正常,但通过HTTPS加载任何东西给我错误的HTTP内容不安全。 尝试通过互联网通过反向代理加载任何HTTPS网站看起来非常错误。 在内部加载工作得很好。 例子 – http://i.imgur.com/i9mYgYe.png – 这应该是WordPress的pipe理控制台,它看起来像90年代的东西。 下面是我使用的nginxconfiguration – server { listen 80; server_name domain1.com; location / { proxy_pass http://192.168.1.149/; proxy_set_header Host $host; } } # HTTPS server server { listen 443 ssl; server_name domain1.com; error_log /tmp/error.log; ssl on; ssl_certificate_key /etc/nginx/ssl/server.key; ssl_certificate /etc/nginx/ssl/server.crt; location / { proxy_pass http://192.168.1.149/; proxy_set_header […]

在nginx中使用fastcgi_keep_conn是否会提高php-fpm的性能?

nginx 文档说,如果fastcgi_keep_conn没有打开,keepalive for fastcgi将无法工作。 但是,我无法find任何进一步的细节。 我已经在服务器范围内启用了Keepalive。 我正在使用php-fpm。 使用fastcgi_keep_conn有什么问题需要注意?

针对真实用户IP自定义AWS ELB的日志条目

我想更改AWS ELB的日志logging格式,以便logging真实的用户IP。 我目前的服务器设置包含以下几层代理: CloudFlare – > AWS ELB – > Nginx(EC2) 通过使用适当的nginx模块,我可以使用X-Forwarded-For头部在EC2实例的日志中获得真实的客户端IP。 但是,我无法find一种方法来configurationAWS ELB以将日志logging在由CloudFlare设置的X-Forwarded-For中。 我想定制AWS ELB生成的日志条目来logging真实的用户IP,这样我就可以分析将来的完整日志,而不是从每个EC2实例收集日志。 有没有办法做到这一点?