1

I recently bought a linode 1GB plan. Installed Apache on it, had my website up and running on it. However I installed gitlab on the server and mapped it to a sub-domain. Since the installation guides recommended using Nginx as the server, I installed it and is running on port 80. Currently my apache is not running since there are port conflicts. But I fixed it by editing the /etc/apache2/ports.conf file and instructing apache to serve on a different port. Now when I visit the main domain that is pointing to a port(8000) and using apache doesn't show up. gitlab is installed at http://gitlab.myserver.com and I am able to access it., but if I try to navigate to http://myserver.com, I get the content of http://gitlab.myserver.com

My gitlab config serving under Nginx is as follows:

# GITLAB
# Maintainer: @randx
# App Version: 5.0

upstream gitlab {
 server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
  listen my_server_ip default_server;  # e.g., listen 192.168.1.1:80; In most    cases *:80 is a good idea
  server_name gitlab.myserver.com;         # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;

# individual nginx logs for this gitlab vhost
access_log  /var/log/nginx/gitlab_access.log;
error_log   /var/log/nginx/gitlab_error.log;

location / {
  # serve static files from defined root folder;.
  # @gitlab is a named location for the upstream fallback, see below
  try_files $uri $uri/index.html $uri.html @gitlab;
}

# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
  proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
  proxy_connect_timeout 800; # https://github.com/gitlabhq/gitlabhq/issues/694
  proxy_redirect     off;

  proxy_set_header   X-Forwarded-Proto $scheme;
  proxy_set_header   Host              $http_host;
  proxy_set_header   X-Real-IP         $remote_addr;

  proxy_pass http://gitlab;
 }
}

My Apache config for myserver.com is as follows:

# domain: myserver.com
# public: /home/me/public/myserver.com/

<VirtualHost *:8000>
 # Admin email, Server Name (domain name), and any aliases
 ServerAdmin webmaster@myserver.com
 ServerName  www.myserver.com
 ServerAlias myserver.com

 # Index file and Document Root (where the public files are located)
 DirectoryIndex index.html index.php
 DocumentRoot /home/me/public/myserver.com/public

 # Log file locations
 LogLevel warn
 ErrorLog  /home/me/public/myserver.com/log/error.log
 CustomLog /home/me/public/myserver.com/log/access.log combined
</VirtualHost>

Where am I going wrong?

4

2 回答 2

1

一个好的解决方案是继续在端口 80 上运行 Nginx,同时向 Nginx 添加代理指令以充当在 Apache 上运行的特定域的代理。Nginx 配置示例:

server {
    server_name  www.myserver.com;
    server_name myserver.com;

   location / {
      proxy_pass http://127.0.0.1:8000;
   }
}

我自己做这个,效果很好。

于 2013-08-01T15:57:04.887 回答
0

我解决了这个问题。问题出在我的 gitlab 配置中的以下行:

server {
  listen my_ip default_server;
  server_name gitlab.myserver.com;         # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;
  ......
}

我将其更改为以下内容:

server {
      listen 80;
      server_name gitlab.myserver.com;         # e.g., server_name source.example.com;
      server_tokens off;     # don't show the version number, a security best practice
      root /home/git/gitlab/public;
      ......
    }

我按照您的说明使用 proxy_pass 通过 nginx 在 apache 上提供站点服务

非常感谢..干杯....

于 2013-08-02T16:43:20.487 回答