$ sudo apt install apache2-utils # Debian系
$ sudo yum install httpd-tools # RedHat系
sudo htpasswd -c -b /etc/nginx/.htpasswd {username} {password}
location / {
auth_basic "Restricted"; # 認証時に表示されるメッセージ
auth_basic_user_file /etc/nginx/.htpasswd; # .htpasswdファイルのパス
}
openssl req -new -x509 -sha256 -newkey rsa:2048 -days 365 -nodes -out nginx.pem -keyout nginx.key
mkdir -p /etc/nginx/ssl/
cp nginx.key /etc/nginx/ssl/nginx.key
cp nginx.pem /etc/nginx/ssl/nginx.pem
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name _;
ssl_certificate /etc/nginx/ssl/nginx.pem;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /mlflow {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host http://mlflow:5000/;
proxy_pass http://mlflow:5000/;
proxy_redirect off;
}
}
server {
listen 5000;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host http://mlflow:5000/;
proxy_pass http://mlflow:5000/;
proxy_redirect off;
}
}