简体   繁体   English

使用NGINX在Ubuntu AWS EC2实例上远程访问Supervisord Web Gui Dashboard

[英]Set up Supervisord Web Gui Dashboard to Be Accessible Remotely on Ubuntu AWS EC2 Instance with NGINX

My Objective: I am using an AWS EC2 Instance with Ubuntu running on it. 我的目标:我正在使用运行Ubuntu的AWS EC2实例。 I am using supervisord to start and monitor my long running processes and I want to use the built-in web GUI dashboard to monitor my long running processes. 我正在使用supervisord来启动和监视我长时间运行的进程,我想使用内置的Web GUI仪表板来监视我长时间运行的进程。

My Stuck Point: I can find instructions on how set this up, but I couldn't find out how to set this up on an ec2 instance. 我的坚持点:我可以找到关于如何设置它的说明,但我无法找到如何在ec2实例上设置它。 I can only access my AWS ec2 instance via ssh command line currently. 我目前只能通过ssh命令行访问我的AWS ec2实例。 I want to be able to view the dashboard from a browser in my office on my laptop. 我希望能够通过笔记本电脑上办公室的浏览器查看仪表板。

My impression is that I need to configure nginx to "serve" this gui status page. 我的印象是我需要配置nginx来“服务”这个gui状态页面。

My /etc/nginx/sites-available/supervisord file: 我的/etc/nginx/sites-available/supervisord文件:

server {

  location / supervisord/ {
    proxy_pass http://127.0.0.1:9001/;
    proxy_http_version 1.1;
    proxy_buffering     off;
    proxy_max_temp_file_size 0;
    proxy_redirect     default;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header   Connection       "";
  }

}

My guess here is that I can just change the http://127.0.0.1:9001 to the IPV4 address of my actual server. 我的猜测是我可以将http://127.0.0.1:9001更改为我实际服务器的IPV4地址。 I know my server has tcp listener on port 9001. via the results of netstat -tulpn | grep LISTEN 我知道我的服务器在端口9001上有tcp监听器。通过netstat -tulpn | grep LISTEN的结果 netstat -tulpn | grep LISTEN

tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      -

My /etc/supervisord.conf file: 我的/etc/supervisord.conf文件:

[inet_http_server]          ; inet (TCP) server disabled by default
port=127.0.0.1:9001         ;

[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=debug               ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)
nocleanup=true              ; (don't clean up tempfiles at start;default false)
childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
;serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket

; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.

[program:my_program]
command=my_program.py ; the program (relative uses PATH, can take args)
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1                    ; number of processes copies to start (def 1)
autostart=true                ; start at supervisord start (default: true)
startsecs=3                   ; # of secs prog must stay up to be running (def. 1)

When I do curl http://127.0.0.1:9001 I get the entire index.html page returned to me as text of the supervisor GUI. 当我curl http://127.0.0.1:9001我将整个index.html页面作为主管GUI的文本返回给我。

I know: 1. The service is up 2. Port 9001 is open and there is a service listening on that port. 我知道:1。服务已启动2.端口9001已打开,并且有一个服务侦听该端口。

I don't know: 1. How to get to it from my laptop in a browser :( 我不知道:1。如何从我的笔记本电脑在浏览器中找到它:(

I did finally figure this out. 我终于搞清楚了。

  1. Open ports 80 and 443 for your ec2 instance using your security group. 使用安全组打开ec2实例的端口80和443。 First identify which security group your ec2 instance is in. In your ec2 dashboard if you select your ec2 instance, you will be able to see what security group it is in in that same row, you may have to scroll to the right to see it. 首先确定你的ec2实例所在的安全组。在你的ec2仪表板中,如果选择你的ec2实例,你将能够看到它在同一行中的安全组,你可能需要向右滚动才能看到它。 Go to the security groups dashboard and select your security group. 转到安全组仪表板并选择您的安全组。 Set it to something like this, you can make it more restrictive later, this is just for now to get it going: 将它设置为这样的东西,你可以在以后使它更具限制性,这只是为了让它继续下去: 安全组规则

  2. Make this /etc/nginx/sites-available/supervisord file: 制作这个/etc/nginx/sites-available/supervisord文件:

upstream supervisord {
server localhost:9001 fail_timeout=0;
}

server {
        listen 80;
        server_name ec2-**-***-**-**.compute-1.amazonaws.com;
        access_log /var/log/access_supervisor.log;
        error_log /var/log/error_supervisor.log;

        location / {

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;

                proxy_pass http://supervisord;
        }

}

Ok, so where I have server_name ec2-**-***-**-**.compute-1.amazonaws.com; 好的,所以我有server_name ec2-**-***-**-**.compute-1.amazonaws.com; You need to put your Public DNS (IPV4). 您需要放置您的公共DNS(IPV4)。 If you go to your ec2 dashboard and select your instance you will see a "Description" tab at the bottom of the screen where you can get this info. 如果您转到ec2仪表板并选择您的实例,您将在屏幕底部看到一个“描述”选项卡,您可以在其中获取此信息。 I put * here so as not to expose mine, but you will put actual numbers there, not asterisks. 我把*放在这里以免暴露我的,但你会把实际的数字放在那里,而不是星号。

  1. Make a symlink to it: 为它做一个符号链接:
sudo ln -s /etc/nginx/sites-available/supervisord /etc/nginx/sites-enable/supervisord
  1. Restart nginx: 重启nginx:
sudo nginx -s reload
  1. Go to ec2- -* - - .compute-1.amazonaws.com in your browser 在浏览器中转到ec2- - * - - .compute-1.amazonaws.com

Reference: https://www.dangtrinh.com/2013/11/supervisord-using-built-in-web.html 参考: https//www.dangtrinh.com/2013/11/supervisord-using-built-in-web.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM