AWSのAMIを使ってRStudioを構築する方法(2018.12)

AWSのAMIを使ってRStudioを構築する方法(2018.12):

R Studio Server(WebUIでR言語が利用できる分析環境)を、

AWS(Amazon Web Service)のAMI(Amazon Machine Image)を利用してサクッと構築する。


HTTP版

以下のサイトでRSutido用のAMIが提供されています。

インスタンスを作成して、セキュリティグループの設定を行いましょう。

詳細な手順は省略します。

以下のURLでログインできればOKです。

  • http://〜インスタンスのIPv4〜/
  • Username: rstudio
  • Password: 〜インスタンスID〜


rstudio_demo_graphics.png



HTTPS化

イマドキHTTPS化は常識。Chromeからも警告されます。
http_security_alert.png

以下のようなネットワーク構成にします。

ブラウザ 
| HTTPS(443) 
ELB (ここに証明書を置く) 
| HTTP(80) 
Nginx 
| TCP(8787) 
R Studio 
デフォルトの設定だとHTTPS経由でアクセスした際にlocalhost:8787にリダイレクトされてしまうので、Nginxの設定を書き換える。

Nginx再起動時の認証は「2.rstudio」を選択、パスワードはインスタンスID。

$ ssh ubuntu@54.95.161.241 -i ~/.ssh/id_rsa_rstudio.pem 
 
$ sudo vi /etc/nginx/RStudioAMI/rstudio.conf 
 
# 変更点は以下の通り。この記事のポイントはここね 
@@ -1,9 +1,11 @@ 
 location / { 
   proxy_pass http://localhost:8787; 
-  proxy_redirect http://localhost:8787/ $scheme://$host/; 
+  proxy_redirect http://localhost/ https://$host/; 
   proxy_http_version 1.1; 
   proxy_set_header Upgrade $http_upgrade; 
   proxy_set_header Connection $connection_upgrade; 
+  proxy_set_header Host $host; 
+  proxy_set_header X-Forwarded-Proto https; 
   proxy_read_timeout 20d; 
   access_log /var/log/nginx/rstudio-access.log; 
   error_log  /var/log/nginx/rstudio-error.log; 
 
$ service nginx restart 
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === 
Authentication is required to restart 'nginx.service'. 
Multiple identities can be used for authentication: 
 1.  Ubuntu (ubuntu) 
 2.  rstudio 
Choose identity to authenticate as (1-2): 2 
Password:  
==== AUTHENTICATION COMPLETE === 
ELBを構築する。プロトコルはHTTPS(443)。

証明書、ターゲットグループ、セキュリティグループは適当に。

ブラウザからhttps経由でアクセスできるようになっている事を確認して、

httpは遮断しておきましょう。

以上です。

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)