Private pages for a private Github repo

GithubGithub Pages

Github Problem Overview


Couldn't find anything in the github documentation and also here on SO. But I was wondering if there could be a http://foo.github.com for a private repository named foo which is accessible only one had access to the foo repository itself.

I remember having read something about github pages always being public but can't seem to find that anymore.

And surprisingly, I can't seem to find anyone else asking the question either.

Github Solutions


Solution 1 - Github

I had raised a support ticket against Github and got a response confirming the fact that ALL pages are public. I've now requested them to add a note to help.github.com/pages.

Solution 2 - Github

According to GitHub Pages documentation:

>All project repositories are ready to use the generator for publishing. However, please note that private repositories will publish pages that are public.

So no, at this time there is no way to create private GitHub pages from a private GitHub repository.

EDIT:

A simple workaround

A workaround for some situations that might be helpful is to simply rename the repo to something other than the GitHub pages format while you want it to be private (for example in a development phase) and when ready to make it public then correct the name. Obviously this still doesn't help if you are looking for a way to publish pages that have authentication, but if you just want to hide a GH pages project while it's in progress, this could help.

An actual Auth Wrapper for Jekyll (GitHub pages)

Alternatively, there is a project called Jekyll Auth that GitHubber @benbalter made for such use. Jekyll Auth provides a basic authentication wrapper for jekyll projects, including GitHub pages. See the repo's README for use.

Solution 3 - Github

Many answers are outdated (pre-Microsoft acquisition/free private repos). This one was written after the announcement of free private repos.

Github pages are not available on free private repos for individuals, as shown in the repo settings:

enter image description here

2020 (most basic plan is now "Team"):

upgrade to github team or make this reposiory public to enable Pages

NOTICE

All pages are public, even if you upgrade. Upgrading only enables the Pages feature on private repos, just like it enables other features. The Pages feature is publicly available static web hosting.

Solution 4 - Github

The page.github.com does mention:

> Github Pages are hosted free and easily published through our site,

Without ever mentioning access control.

The GitHub page help doesn't mention any ACL either.
They are best managed in a gh-pages branch, and can be managed in their own submodule.
But again, without any restriction in term of visibility once published by GitHub.

Solution 5 - Github

There is an article with a working idea on how to request oAuth authorization before loading static content dynamically:

(archive.org) Securing Site That Runs on Github Pages With JSON Backend In Private Repository (original article that became 404)

Content should be stored in a secret GitHub repository with a viewer having read access to it. GitHub pages stores only the serving JS code.

Solution 6 - Github

This is finally possible for GitHub Enterprise Cloud customers: Access control for GitHub Pages.

> To enable access control on Pages, navigate to your repository > settings, and click the dropdown menu to toggle between public and > private visibility for your site.

enter image description here

Solution 7 - Github

As outlined above, Github pages do not support that functionality. I had the same issue when our team decided to host project documentation (static HTML) internally and privately.

I ended up creating a service https://www.privatehub.cloud It is basically a simple proxy server with Github OAuth authentication, so it merely returns your GitHub repository content with a proper MIME type. By design, only who have access to foo will be able to see foo content at https://bar-foo.privatehub.cloud. From functional point of view, you can think about it as a simplified GitHub pages with built-in authentication.

Unfortunately, Github OAuth does not allow to request read-only access to private repos, so the server needs the full access (obviously, it does not write anything to your repo). As GitHub API allows to retrieve files under 1 Mb only, the service cannot return larger files. Yet, I found the service is quite suitable for small projects for internal documentation or staging version of a website.

Solution 8 - Github

Jan. 2021: this is now possible for GitHub Enterprise (so: not yet for github.com).
See:

Access control for GitHub Pages

> > GitHub Pages now gives you the option to limit access, making the site visible only to users with access to the repository that published the Page.
> > With access control, you can use GitHub Pages to publish and share internal documentation and knowledge across your enterprise. > >As part of this release, we are introducing the following capabilities: > > - Repo admins can select whether GitHub Pages sites are publicly visible or limited to users who have access to the repository. >- Both private and internal repositories support private visibility. With an internal repository, everyone in your enterprise will be able to view the Page with the same credentials they use to login to github.com >- Org admins can configure the visibility options that members will be able to select for their Page. For example, you can enforce that your members can only publish content privately. > > This feature is generally available today on GitHub Enterprise Cloud.
To enable access control on Pages, navigate to your repository settings, and click the dropdown menu to toggle between public and private visibility for your site. > > Private publishing for GitHub Pages -- https://i2.wp.com/user-images.githubusercontent.com/55514721/101868473-46f81880-3b32-11eb-9708-a8537f41adaf.png?ssl=1

Solution 9 - Github

So sad It's 2020 and we are not able to have private GithubPäges:

enter image description here

Solution 10 - Github

As an alternative, it is currently possible to do exactly what the OP is asking to do, using GitLab, rather than GitHub. See docs for feature GitLab Pages access control. Since GitHub doesn't support this feature, if porting a project over to GitLab is not an issue, this is a good workaround.

Solution 11 - Github

If you press admin on a private repo and scroll down to the part about pages, it writes that it'll be public. I'll check later if .htaccess control or similar is possible, but I don't have much hope for it.

Solution 12 - Github

This GitHub app: https://github.com/apps/priv-page allows users to have private pages for their private repositories.

Solution 13 - Github

You could host password in a repository and then just hide the page behind hidden address, that is derived from that password. This is not a very secure way, but it is simple.

Demonstration

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkashyapView Question on Stackoverflow
Solution 1 - GithubkashyapView Answer on Stackoverflow
Solution 2 - GithubJoel GlovierView Answer on Stackoverflow
Solution 3 - GithubCoreyView Answer on Stackoverflow
Solution 4 - GithubVonCView Answer on Stackoverflow
Solution 5 - GithubTautrimasPajarskasView Answer on Stackoverflow
Solution 6 - Githubuser2355282View Answer on Stackoverflow
Solution 7 - GithubgriegView Answer on Stackoverflow
Solution 8 - GithubVonCView Answer on Stackoverflow
Solution 9 - GithubjulianmView Answer on Stackoverflow
Solution 10 - GithubpostylemView Answer on Stackoverflow
Solution 11 - GithubRohde FischerView Answer on Stackoverflow
Solution 12 - GithubsbalciView Answer on Stackoverflow
Solution 13 - GithubOzboltView Answer on Stackoverflow