You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法从公网访问Oracle云Compute Instance上的Angular应用求助

问题描述

我在Oracle云拥有一台可正常SSH连接的Compute Instance,其上运行着部署在localhost:4200的Angular应用。为实现公网访问,我已安装配置Nginx,但通过Oracle提供的公网IP访问时出现ERR_CONNECTION_TIMED_OUT错误,且无法ping通服务器(据了解云虚拟机此情况属正常)。请问如何才能访问我的Angular应用?

已配置信息

子网入站规则

子网入站规则

Nginx配置文件(/etc/nginx/sites-available/default)

listen 80 default_server;
listen [::]:80 default_server;

location / {
    proxy_pass http://localhost:4200;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
}

firewalld已开放端口

80/tcp 443/tcp 4200/tcp

解决步骤
  • 检查Oracle云安全列表配置
    Oracle云的子网规则之外,还需为实例所属安全列表添加80端口的入站允许规则:

    1. 进入Oracle云控制台,找到目标实例
    2. 在"资源"标签下找到关联的安全列表
    3. 编辑入站规则,添加:
      • 源:0.0.0.0/0(或指定可信IP段)
      • 协议:TCP
      • 目标端口:80
    4. 保存规则
  • 验证Nginx运行状态
    执行命令检查Nginx是否正常运行:

    sudo systemctl status nginx
    

    未运行则启动:

    sudo systemctl start nginx
    

    设置开机自启:

    sudo systemctl enable nginx
    

    同时验证配置文件合法性:

    sudo nginx -t
    
  • 确认Angular应用监听状态
    检查4200端口是否被Angular应用占用:

    sudo ss -tulpn | grep 4200
    

    确保输出显示localhost:4200有监听进程,无则重启Angular应用。

  • 核对系统防火墙规则
    重新确认firewalld的开放规则:

    sudo firewall-cmd --list-all
    

    若public区域缺少80/tcp规则,添加并重载:

    sudo firewall-cmd --add-port=80/tcp --permanent
    sudo firewall-cmd --reload
    
  • 测试公网访问
    使用curl测试公网IP的连通性:

    curl http://<你的公网IP>
    

    若返回Angular页面内容则配置生效;仍超时则重点排查安全列表与子网规则的优先级。


内容的提问来源于stack exchange,提问作者Guy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 23:47:36