1

最近、linode 1GB プランを購入しました。それにApacheをインストールし、私のウェブサイトを立ち上げて実行しました。ただし、サーバーにgitlabをインストールし、サブドメインにマップしました。インストール ガイドでは Nginx をサーバーとして使用することが推奨されていたため、インストールしてポート 80 で実行しています。現在、ポートの競合があるため、Apache は実行されていません。しかし、/etc/apache2/ports.confファイルを編集し、apache に別のポートでサービスを提供するように指示することで修正しました。ポート(8000)を指しているメインドメインにアクセスすると、Apacheを使用しても表示されません。gitlab は にインストールされてhttp://gitlab.myserver.comおり、アクセスできますが、 に移動しようとするとhttp://myserver.comhttp://gitlab.myserver.com

Nginxで提供する私のgitlab構成は次のとおりです。

# 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;
 }
}

私のApache設定myserver.comは次のとおりです:

# 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>

どこが間違っていますか?

4

2 に答える 2

1

適切な解決策は、Apache で実行されている特定のドメインのプロキシとして機能するプロキシ ディレクティブを Nginx に追加しながら、ポート 80 で Nginx を実行し続けることです。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 に答える