nginx可以在同一个虚拟机上同时运行gitlab和taiga.io吗?

我在同一台虚拟机上运行GitLab和Taiga.io (即共享相同的IP)有困难。 两者都使用nginx。 我的虚拟机运行Debian 8。

我遵循Debian 8的GitLab的经典Omnibus安装 ,当我在浏览器上input我的虚拟机的IP时,gitlab被正确的服务,并且一切顺利。

然后closures它( sudo gitlab-ctl stop ),然后按照生产环境设置安装Taiga。 根据该文档,它使用Gunicorn和Circus for taiga-back(服务于REST API)以及用于服务前端的nginx。 一旦/etc/nginx/sites-available|enabled/taiga~/taiga-back/settings/local.py~/taiga-front-dist/dist/conf.json都使用相同的IP地址设置,而nginx重新启动( sudo service nginx restart )一切顺利。

现在,可以使用不同的端口(比如说8080 )来更改上述的所有Taiga IP地址,重新启动nginx,并且现在通过IP地址8080提供Taiga。 一切都好!

当我重新启动GitLab( sudo gitlab-ctl start )时,它说一切顺利。 但是,当我尝试访问它(在默认端口80),我得到一个502

如果我切换Taiga并重新启动GitLab,hoho,GitLab可用! 基本上,我只能单独拥有它们,但不能同时拥有它们。

我也尝试在Taiga 80端口上保留Taiga,并在8080端口上移动GitLab(通过更改/etc/gitlab/gitlab.rb文件中的端口并运行sudo gitlab-ctlr reconfigure ),但是我从未设法成功运行它。

我也试着configurationGitLab使用系统nginx(而不是embedded的),也就是Taiga使用的系统。 为此,我在gitlab.rb后面的gitlab.rb禁用了nginx,并使用了这个omnibus(non-ssl)配方:

 ## GitLab 8.3+ ## ## Lines starting with two hashes (##) are comments with information. ## Lines starting with one hash (#) are configuration parameters that can be uncommented. ## ################################## ## CONTRIBUTING ## ################################## ## ## If you change this file in a Merge Request, please also create ## a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests ## ################################### ## configuration ## ################################### ## ## See installation.md#using-https for additional HTTPS configuration details. upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket; } ## Normal HTTP host server { ## Either remove "default_server" from the listen line below, ## or delete the /etc/nginx/sites-enabled/default file. This will cause gitlab ## to be served if you visit any address that your server responds to, eg. ## the ip address of the server (http://xxxx/)n 0.0.0.0:80 default_server; listen 80 default_server; #listen [::]:80 default_server; server_name gitlab.<replaced with company URL> <replace with VM IP address>; ## Replace server_tokens off; ## Don't show the nginx version number, a security best practice root /opt/gitlab/embedded/service/gitlab-rails/public; ## See app/controllers/application_controller.rb for headers set ## Individual nginx logs for this GitLab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { client_max_body_size 0; gzip off; ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; 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_pass http://gitlab-workhorse; } } 

连同针对泰加:

 server { listen 8080 default_server; server_name taiga.<replaced with company URL> <replace with VM IP address>; large_client_header_buffers 4 32k; client_max_body_size 50M; charset utf-8; access_log /opt/taiga/logs/nginx.access.log; error_log /opt/taiga/logs/nginx.error.log; # Frontend location / { root /opt/taiga/taiga-front-dist/dist/; try_files $uri $uri/ /index.html; } # Backend location /api { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8001/api; proxy_redirect off; } # Django admin access (/admin/) location /admin { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8001$request_uri; proxy_redirect off; } # Static files location /static { alias /opt/taiga/taiga-back/static; } # Media files location /media { alias /opt/taiga/taiga-back/media; } } 

有了/etc/nginx/sites-enabled这两个configuration,重新启动后( sudo service nginx restart ),我的Taiga服务器可以通过端口8080访问,但奇怪的是,gitlab服务器无法访问了。 没有502,但连接超时!

任何人知道nginx的想法? 任何帮助将不胜感激!

感谢我的IT提供商的帮助,我们find了一个解决scheme,沿着@Alex_hha的出发点回答:将Taiga绑定到端口8080( LSNED …)是一个错误。

最后,我在我的虚拟机中使用Debian安装了nginx作为反向代理,禁用了GitLab中的embedded式nginx(通过编辑/etc/gitlab/gitlab.rb文件),并在/etc/nginx/sites-availableconfiguration了Taiga和Gitlabconfiguration文件/etc/nginx/sites-available (以及符号链接到/etc/nginx/sites-enabled ),如下所示:

大雅:

 server { listen 80 default_server; server_name taiga.<company URL> <VM IP address>; 

并保持不变。 而对于Gitlab:

 server { listen 80; server_name gitlab.<company URL>; large_client_header_buffers 4 32k; client_max_body_size 50M; charset utf-8; access_log /opt/gitlab/logs/nginx.access.log; error_log /opt/gitlab/logs/nginx.error.log; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; 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; } } 

所以两者都通过端口80访问,但是给定请求的URL,调用正确的服务。 注意GitLabconfiguration中缺lessdefault_server

这个configuration的组合使得所有的GitLabstream量都进入到GitLab中,而其他任何东西(甚至无效的URL)都以Taiga服务结束。

不要为Taiga使用端口8080,或者至less不要将nginx绑定到localhost:8080。 对于Taiga,你可以绑定nginx到一些特定的外部接口,例如类似下面的东西

 server { listen 192.168.127.1:8080; ... } 

我在同一台机器上使用Gitlab和Jenkins,没有任何问题。 他们两个在端口8080

 # lsof -n -P -i tcp:8080 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 18983 jenkins 155u IPv6 639617 0t0 TCP 192.168.88.87:8080 (LISTEN) ruby 19098 git 9u IPv4 113752 0t0 TCP 127.0.0.1:8080 (LISTEN) ruby 19141 git 9u IPv4 113752 0t0 TCP 127.0.0.1:8080 (LISTEN) ruby 19144 git 9u IPv4 113752 0t0 TCP 127.0.0.1:8080 (LISTEN) ruby 19147 git 9u IPv4 113752 0t0 TCP 127.0.0.1:8080 (LISTEN) ruby 19150 git 9u IPv4 113752 0t0 TCP 127.0.0.1:8080 (LISTEN)