News for hackers. Stuff that matters.
Re:Please stop serving .git to the outside world by scubbo on Monday June 10, 2013 @12:42PM (#5855501)
I feel incredible stupid asking this, but...how?

I'm running a (very small) personal site on lighttpd, and updating it via git. I checked my.server.com/.git/config - and was duly served the config file. Eek!

So I edited my /var/www/lighttpd/lighttpd.conf file, and added the following lines: $HTTP["url"] =~ ".git" { url.access-deny = ("") }

and (I have used [asterisk] for the symbol, here, as otherwise it rendered my text italic)

$HTTP["host"] =~ "(.[asterisk])" { url.redirect = ( "^/.git(.*)" => "%1/nope.html" ) }

And restarted the server.

But my.server.com/.git/config still served up the config file. What am I missing?

Re:Please stop serving .git to the outside world by dalore on Monday June 10, 2013 @12:57PM (#5855602)
Another way would be to only deploy releases to your server and not have the .git directory at all. Look at git archive.
Re:Please stop serving .git to the outside world by fallenhitokiri on Monday June 10, 2013 @01:26PM (#5855744)
Instead of messing around with access and redirect stuff I would suggest, as others have in this thread, that you just put your files in a subdirectory and use this subdirectory as root for lighttpd.

Problem solved with two commands and you can also add additional stuff to your repository like sources before they went through different processors (coffee script, SASS,...) or various drafts. This way you also have a full copy of everything you need for your site in case something happens to your workstation.

Re:Please stop serving .git to the outside world by scubbo on Tuesday June 11, 2013 @06:08AM (#5860757)
OK, now I'm REALLY confused.

I've moved all my documents from /var/www/lighttpd/mainSite to /var/www/lighttpd/mainSite/webdocs (leaving .git in .../mainSite).

I've updated /etc/lighttpd/lighttpd.conf to point at /var/www/lighttpd/mainSite/webdocs, and confirmed that it's pointing at the right place by editing a file, and confirming that that change shows up on the site.

I've confirmed that there is no .git folder in webdocs (you never know!)

But calling my.site.com/.git/config still serves a file!?

Time to go ask on some lighttpd fora...

Re:Please stop serving .git to the outside world by _wmd on Tuesday June 11, 2013 @06:22AM (#5860792)
Hit refresh in your browser. :)
Re:Please stop serving .git to the outside world by scubbo on Tuesday June 11, 2013 @07:16AM (#5860946)
Cleared the cache, refreshed, it's still there. Weirdness abounds.
Re:Please stop serving .git to the outside world by scubbo on Tuesday June 11, 2013 @05:35AM (#5860666)
So, instead of having:

.git some_page.html some_css.css

You would advocate: .git web_docs/some_page.html web_docs/some_css.css

?

Makes sense. It will require some reorganisation, but it seems (from everyone's comments) to be best practice. Thanks!

(Still kinda bugs me that I can't work out how to prevent lighttpd from serving individual files, though!)

Re:Please stop serving .git to the outside world by kl4m on Monday June 10, 2013 @10:33PM (#5859236)
You can turn the .git directory in a simple "shortcut"

To explain it briefly:

  mv .git ../git-repo
  echo "gitdir: ../git-repo" > .git