Skip to content

Instantly share code, notes, and snippets.

@MozyOk
Created April 26, 2023 00:16
Show Gist options
  • Save MozyOk/b2f1a4159f9cf58705aba6511f4984f5 to your computer and use it in GitHub Desktop.
Save MozyOk/b2f1a4159f9cf58705aba6511f4984f5 to your computer and use it in GitHub Desktop.
index html with basic auth on the railway
  1. https://github.com/railwayapp-templates/nginx をもとにして作成
  2. htpasswd -c .htpasswd user 実行して認証用ファイル生成する
  3. Dockerfile をこんな感じに更新して
FROM nginx:alpine
COPY .htpasswd /etc/nginx/.htpasswd
COPY nginx.conf /etc/nginx/nginx.conf
COPY site /usr/share/nginx/html
  1. nginx.confはこんな感じに更新
events {}
http {
  server {
    listen 80;
    root /usr/share/nginx/html;
    index index.html index.htm;

    location / {
        auth_basic "認証が必要です";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment