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

如何配置Nginx在DigitalOcean Droplet上运行Sinatra应用而非默认页面?

解决Sinatra应用Nginx反向代理问题的步骤
  • 修正Nginx配置的拼写错误
    你的myapp.com配置里的prox_pass是拼写错误,正确指令为proxy_pass。另外建议用localhost代替myapp.com作为代理目标,避免DNS解析开销,修改后的location块如下:

    location / {
            proxy_pass http://localhost:4567;
    }
    
  • 将配置文件链接到sites-enabled目录
    Nginx仅加载/etc/nginx/sites-enabled/下的配置文件,需创建软链接让配置生效:

    sudo ln -s /etc/nginx/sites-available/myapp.com /etc/nginx/sites-enabled/
    
  • 禁用默认Nginx配置(推荐)
    若默认的default配置仍在sites-enabled目录中,会优先抢占请求处理。可删除其软链接:

    sudo rm /etc/nginx/sites-enabled/default
    
  • 验证配置并重载Nginx服务
    先检查配置语法是否正确:

    sudo nginx -t
    

    若输出syntax is ok和test is successful,立即重载Nginx使新配置生效:

    sudo systemctl reload nginx
    
  • 确认Thin服务的监听状态
    确保Thin确实监听在目标端口,可用以下命令验证:

    sudo ss -tulpn | grep thin
    

    输出需显示Thin监听在127.0.0.1:4567或0.0.0.0:4567,确保代理目标地址正确。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 16:10:33