簡體   English   中英

如何訪問運行在ec2實例上的localhost:4200

[英]How access to localhost:4200 running on ec2 instance

在我的 EC2 上,我加載了運行完美流程的 python 腳本,我想從 web 瀏覽器訪問 UI。 此 UI 在 localhost:4200 上運行。

[ec2-user@ip-xxxx-xx-xx-xx ~]$ prefect orion start 

 ___ ___ ___ ___ ___ ___ _____    ___  ___ ___ ___  _  _
| _ \ _ \ __| __| __/ __|_   _|  / _ \| _ \_ _/ _ \| \| |
|  _/   / _|| _|| _| (__  | |   | (_) |   /| | (_) | .` |
|_| |_|_\___|_| |___\___| |_|    \___/|_|_\___\___/|_|\_|

Configure Prefect to communicate with the server with:

    prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api

View the API reference documentation at http://127.0.0.1:4200/docs

Check out the dashboard at http://127.0.0.1:4200

為此,我創建了一個入站安全性: 在此處輸入圖像描述

我試圖通過 url 使用 chrome 訪問它: https://ec2-x-xxx-xxx-xx.eu-west-1.compute.amazonaws.com:4200 ( <EC2-IP:Port> )

但是我在 chrome 選項卡中出現以下錯誤:

無法訪問此網站ec2-x-xxx-xx-xx.eu-west-1.compute.amazonaws.com 未授權連接。”

在另一個終端連接到我的實例我可以 curl 本地主機:

[ec2-user@ip-xxx-xx-xx-xx ~]$ curl http://127.0.0.1:4200
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="apple-touch-icon" sizes="180x180" href="/ico/apple-touch-icon.png">
    <link rel="icon" id="favicon-32" type="image/png" sizes="32x32" href="/ico/favicon-32x32.png">
    <link rel="icon" id="favicon-16" type="image/png" sizes="16x16" href="/ico/favicon-16x16.png">
    <link rel="manifest" href="/ico/site.webmanifest">
    <link rel="mask-icon" href="/ico/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Prefect Orion</title>
    <script type="module" crossorigin src="/assets/index.c3b9a55d.js"></script>
    <link rel="stylesheet" href="/assets/index.dbace0e3.css">
  </head>
  <body>
    <div id="app"></div>
    
  </body>
</html>

編輯:根據@Jayce 的建議,我將 prefect IP 綁定到 0.0.0.0,以便從 web export PREFECT_ORION_API_HOST=0.0.0.0訪問它

我現在可以連接到在我的實例上運行的 UI:

在此處輸入圖像描述

但在此配置中,完美不要檢索我在 EC2 上啟動的流程。 我還需要更改 prefect api 路徑: export PREFECT_API_URL="http://x.xxx.xxx.xx:4200/api"

如果你想從 .network 訪問它,你必須像默認那樣綁定到 0.0.0.0 ip 而不是 127.0.0.1。

我從未使用過 prefect,但從它的文檔中,您可以嘗試使用此命令更改綁定 ip:

export PREFECT_ORION_API_HOST=0.0.0.0

使用公眾號IP地址

http://<public_ip>:4200/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM