问题
I cannot fix the icons on Gitlab bring proxied by Apache 2.4. My failure may be because I am not using passenger (passenger provided its own set of problems that were much deeper), but I took all the steps in running it under a proxied /gitlab
. I also ran:
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab
I restarted Apache as well. No improvement. The icons were still missing (or I should say the font woff
file returns status 200
to the browser but with a size of 0). This is Gitlab 6.5. In my Apache SSL sites-enabled
conf file, this is what provides an SSL route to the world to our Gitlab:
<Proxy *>
Require all granted
</Proxy>
<Location ~ /(gitlab|assets)>
RequestHeader set X_FORWARDED_PROTO 'https'
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
Require all granted
Options -Multiviews
# 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
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8085/%{REQUEST_URI} [P,QSA]
# needed for downloading attachments but does not work under Location directive
#DocumentRoot /home/git/gitlab/public
</Location>
ProxyPass /gitlab/ http://127.0.0.1:8085/gitlab/
ProxyPassReverse /gitlab/ http://127.0.0.1:8085/gitlab/
ProxyPass /gitlab http://127.0.0.1:8085/gitlab
ProxyPassReverse /gitlab http://127.0.0.1:8085/gitlab
# SOme of the CSS assets were not being generated with "/gitlab", so I proxy those too.
ProxyPass /assets http://127.0.0.1:8085/gitlab/assets
ProxyPassReverse /assets http://127.0.0.1:8085/gitlab/assets
Again, most of it works fine. Only the font resources return with a 0 size to the browser. Should I update the Location directive to a Directory?
Note: gitlab - icons replaced by rectangles did not help. And yes, there are other sites at the 443 port on my server so I can't just take this Apache config on its own port/domain if I don't have to. I likely just need some help understanding Apache 2.4. Am I missing anything in my Apache config?
Resources made use of: https://github.com/gitlabhq/gitlab-recipes/commit/be95bd4f9bd3244641a4c7e55eb75fcc29129ffd , https://github.com/gitlabhq/gitlabhq/issues/2365 , https://github.com/gitlabhq/gitlab-recipes/commit/c6c22b4fb68bbb6efb547cce6605dea4344ba9fe
Also failed with replacing the Location directive: Tried this, but not as successful:
Alias ^/(gitlab|assets) /home/git/gitlab/public
<Directory /home/git/gitlab/public>`
RequestHeader set X_FORWARDED_PROTO 'https'
SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"
Require all granted
Options -Multiviews
# https://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8085/%{REQUEST_URI} [P,QSA]
</Directory>
回答1:
Since it is under a relative root, you still would need to run the following as noted above in order to verify the correct mapping of the assets (which includes icons and CSS URLs):
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab
For you non-relative URL users, leave off the extra relative URL portion
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
You can also restart as noted by @LpLrich :
sudo service gitlab restart
For some older Linux setups instead use:
sudo /etc/init.d/gitlab restart
Then refresh your browser.
Yet none of the above steps worked on my system because, as best as I can say, imperfect Apache setup which I fixed below--including it in case you are finding the same issue of fixing Gitlab correctly but finding the end result failing in the browser. I did change to not using the relative URL root anymore but that doesn't matter so much. This should help Apache fix the issue above as well once the gitlab steps are completed. Sorry, the ProxyPassReverse is the main change you need to notice from the question's Apache setup:
<IfModule mod_ssl.c>
<VirtualHost *:443>
Servername gitlab.my_domain.com
ServerAdmin my_admin@my_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:8080/gitlab
#ProxyPassReverse https://gitlab.my_domain.com/gitlab
# For non-relative URL root
ProxyPassReverse http://127.0.0.1:8080
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
# http://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>
(from https://github.com/gitlabhq/gitlab-recipes/blob/master/web-server/apache/gitlab-ssl-apache2.4.conf)
回答2:
This might help you,
https://github.com/gitlabhq/gitlabhq/issues/3306#issuecomment-15971720
Basically it's saying to run a rake assets:clean
and then a assets:precompile
and then a service gitlab restart
I had precompiled my assets, checked the public/assets folder and could see they existed but some icons were not showing so I cleaned them out, precompiled again and restarted it then they started showing up.
Run
sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production
Then
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/gitlab
And refresh the page, if it's not working try
sudo service gitlab restart
But I looked in my history there now and I couldn't see myself restarting it so I am assuming that when this happened to me I simply cleaned them out and precompiled them again and I didn't have to restart.
来源:https://stackoverflow.com/questions/21768703/how-can-i-get-gitlab-6-5-to-show-its-icons-under-a-apache-2-4-proxy