Подтвердить что ты не робот

Приложение Apache2 ProxyPass для Rails Gitlab

Я пытаюсь настроить прокси с Apache2, чтобы входящие запросы http://myipaddress.com переходили на http://localhost:3000/, где я запускал приложение Gitlab (приложение rails). Следующее - это то, что у меня есть в конфигурационном файле Apache на Ubuntu 10.04. Сначала я могу успешно получить доступ к странице по умолчанию gitlab, но любые последующие запросы, выполненные мной, нажав на другие страницы после этого, перейдите на страницу 404 NOT FOUND. Я могу вручную ввести/gitlab/перед любой из этих неудачных переадресаций, и они работают нормально. Как я могу выполнить эту работу без необходимости переписывать/gitlab/после каждого запроса на перенаправление после первоначального запроса?

## Setup a proxy which listens on the port that gitlabh does ( from start_server.sh )
ProxyRequests Off
ProxyPass /gitlab/ http://localhost:3000/
ProxyPassReverse /gitlab/ http://localhost:3000/
#DocumentRoot /home/gitlabhq/gitlabhq/public
<Proxy http://localhost:3000/>
  Order deny,allow
  Allow from all
</Proxy>

Я понимаю, что у меня мог бы быть код ниже, который бы разрешил мою проблему. Но я не знаю, как изменить префикс службы gitlab rails. Я бы очень признателен за помощь!

ProxyPass /gitlab/ http://localhost:3000/gitlab/
ProxyPassReverse /gitlab/ http://localhost:3000/gitlab/

UPDATE:

Благодаря замечанию Фрика я очень близко подошел к решению этого вопроса. Ниже приведена часть моего файла http.conf. Единственная проблема - когда я нажимаю кнопку "домой" или логотип в приложении gitlab, он пытается перенаправить на gitlab/, который дает мне основной файл index.html из Apache2, говорящий "он работает!". Как я могу настроить это, чтобы позволить мне просто получить /gitlab, и он приведет меня к корневому домашнему виду gitlab?? Спасибо!

## For Gitlab using Apache2 Passenger
## Install on Ubuntu by:
## sudo gem install passenger && sudo passenger-install-apache2-module
## but only after running the install_and_configure_git.py script
## and creating a soft link to the rails gitlab /public directory like so:
## sudo ln -s /home/gitlabhq/gitlabhq/public /var/www/gitlab
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13
PassengerRuby /usr/local/bin/ruby
<VirtualHost *:80>

        ServerName gitlab

        ## Set the overall Document Root
        DocumentRoot /var/www
        <Directory /var/www>
                Allow from all
        </Directory>

        ## Set the Rails Base URI
        RackBaseURI /gitlab
        RailsBaseURI /gitlab
        <Directory /var/www/gitlab>
                Allow from all
                Options -MultiViews
        </Directory>

</VirtualHost>
4b9b3361

Ответ 1

Я наткнулся на этот смысл, который работал на меня. Если он когда-нибудь исчезнет, ​​я отправлю его.


конфигурационный файл unicorn

Редактировать файл /home/gitlab/gitlab/config/unicorn.rb

Найдите строку прослушивания "#{app_dir}/tmp/sockets/gitlab.socket" и прокомментируйте ее. Uncomment line listen "127.0.0.1:8080"

требуемые модули для apache

  • sudo a2enmod proxy
  • sudo a2enmod proxy_balancer
  • sudo a2enmod proxy_http
  • sudo a2enmod переписать

/home/gitlab/gitlab/config/gitlab.conf

<VirtualHost *:80>
  ServerName git.domain.com

  # Point this to your public folder of teambox
  DocumentRoot /home/gitlab/gitlab

  RewriteEngine On

  <Proxy balancer://unicornservers>
    BalancerMember http://127.0.0.1:8080
  </Proxy>

  # Redirect all non-static requests to thin
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]

  ProxyPass / balancer://unicornservers/
  ProxyPassReverse / balancer://unicornservers/
  ProxyPreserveHost on

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  # Custom log file locations
  ErrorLog  /var/log/apache2/gitlab_error.log
  CustomLog /var/log/apache2/gitlab_access.log combined
</VirtualHost>

Ответ 2

<VirtualHost *:80>

        ServerName gitlab

        ## Set the overall Document Root
        DocumentRoot /var/www
        <Directory /var/www>
                Allow from all
        </Directory>

        ## Set the Rails Base URI
        RackBaseURI /gitlab
        RailsBaseURI /gitlab
        <Directory /var/www/gitlab>
                Allow from all
                Options -MultiViews
        </Directory>

</VirtualHost>

Эти настройки в вашем файле конфигурации httpd.conf или вашего сайта должны быть выполнены. Удалите настройки прокси-сервера, если у вас есть, и попробуйте, он будет работать.,

если у вас есть нижние строки вместе с приведенной выше конфигурацией, удалите приведенные ниже строки,

ProxyPass /gitlab/ http://localhost:3000/gitlab/
ProxyPassReverse /gitlab/ http://localhost:3000/gitlab/
Proxy on

Перезагрузите веб-сервер

service apache2 restart

Ответ 3

Извините за сообщение по этому старому вопросу... но на основе текста обновления основного вопроса я создал функциональный суффикс со всеми шагами:

https://gist.github.com/carlosjrcabello/5486422

Ответ 4

Это, если кто-то новый сталкивается с этой проблемой.

Это помогло мне заметить строки ProxyPassReverse. Моя полная проблема и разрешение: fooobar.com/questions/530782/....

<IfModule mod_ssl.c>
<VirtualHost *:443>
  Servername gitlab.my_domain.com
  ServerAdmin [email protected]_domain.com

  SSLCertificateFile /etc/apache2/ssl.crt/gitlab_my_domain.crt
  SSLCertificateKeyFile /etc/apache2/ssl.crt/gitlab_my_domain_private.key
  SSLCACertificateFile /etc/apache2/ssl.crt/gitlab.ca-bundle

  ##### All the other Apache SSL setup skipped here for StackOverflow ####

  ProxyPreserveHost On

  <Location />
    # New authorization commands for apache 2.4 and up
    # http://httpd.apache.org/docs/2.4/upgrading.html#access
    Require all granted

    # For relative URL root "host:your_gitlab_port/relative_root"
    #ProxyPassReverse http://127.0.0.1:8085/gitlab
    #ProxyPassReverse https://gitlab.my_domain.com/gitlab

    # For non-relative URL root
    ProxyPassReverse http://127.0.0.1:8085
    ProxyPassReverse https://gitlab.my_domain.com/
  </Location>

  # apache equivalent of nginx try files
  # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
  # https://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]
  RequestHeader set X_FORWARDED_PROTO 'https'

  # needed for downloading attachments
  DocumentRoot /home/git/gitlab/public

  #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 503 /deploy.html

  LogFormat  "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog      /var/log/apache2/gitlab-ssl_error.log
  CustomLog /var/log/apache2/gitlab-ssl_forwarded.log common_forwarded
  CustomLog /var/log/apache2/gitlab-ssl_access.log combined env=!dontlog
  CustomLog /var/log/apache2/gitlab-ssl.log combined
</VirtualHost>
</IfModule>

(из https://github.com/gitlabhq/gitlab-recipes/blob/master/web-server/apache/gitlab-ssl-apache2.4.conf)

Ответ 5

Я оказался здесь, в то время как Googling для ошибок, с которыми я столкнулся при настройке Rails + единорога, использующего Apache (на порту 80) для прокси-сервера для единорога (на порту 3000). В случае его использования кому-либо еще, здесь моя конфигурация:

<VirtualHost example.com:80>
  ServerAdmin [email protected]
  ServerName example.com
  ServerAlias www.example.com

  ProxyPreserveHost On
  <Location />
      Require all granted
      ProxyPassReverse http://example.com:3000
  </Location>

  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://example.com:3000%{REQUEST_URI} [P,QSA]

  DocumentRoot /home/user/rails-dir/public
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 503 /deploy.html

  LogLevel warn
  ErrorLog /home/user/rails-dir/log/apache-error.log
  CustomLog /home/user/rails-dir/log/apache-access.log combined
</VirtualHost>