1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jenkins on Azureをhttps化する

Posted at

Jenkins on Azureをhttps化をする

Jenkins on Azureで作成したJenkinsにログインするにはデフォルトでは
sshポート転送してlocalhostでログインする必要があり、https://ドメイン〜ではログイン出来ませんでしたので対応しました。
設定自体は簡単にできました。

環境確認

Azure on Jenkinsで作成したvmはすでにnginxが設定されているはずですので
nginxのインストールは必要ありません

$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)

証明書の作成

  • わかりやすいように証明書を保存するディレクトリを作成しておきます。
$ mkdir /etc/nginx/ssl
  • 証明書の作成(有効期限 -days は10年で作成しましたが、適応かえてください)
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt

入力項目はすべてEnterで飛ばしてます

設定ファイルの作成

設定方法はいくつかあると思いますが、自分は/etc/nginx/conf.d/以下にssl用のconfファイルを作成して設定いたしました

$ sudo vi /etc/nginx/conf.d/ssl.conf

# ファイル内容
server {
    listen       443 ssl;
    server_name  ドメイン名;

    ssl           on;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    location / {
        proxy_set_header        Host $host:$server_port;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;

        proxy_pass          http://localhost:8080;
        proxy_read_timeout  90;
    }
}

ネットワークセキュリティーの設定

  • Azure Portalの対象のvmに紐付いているネットワークセキュリティーで443の許可をしてください
  • vm名-nsgの設定画面から適応必要な設定を行います。

これでnginxに設定適用したらhttps://ドメイン〜でログインが行えると思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?