为了账号安全,请及时绑定邮箱和手机立即绑定

在乌布努图 18.04 上部署

在乌布努图 18.04 上部署

人到中年有点甜 2022-09-12 11:00:41
我已经在我的本地计算机上使用ReactPHP工作REST API,我想将其部署在开发服务器上,我在DO上添加了一个新闻数据库域,与nginx进行了讨论,设置了一个正在进行的php索引进程.php我的服务器根文件为ReactPHP应用程序。已允许端口 8000。现在我无法访问我的api路由我的服务器日志显示为默认回显Listening on tls://127.0.0.1:8000$loop->run();在击中子域的路线上,它说<html><head>    <title>502 Bad Gateway</title></head><body bgcolor="white">    <center>        <h1>502 Bad Gateway</h1>    </center>    <hr>    <center>nginx/1.14.0 (Ubuntu)</center></body></html>我的恩金克斯会议server {     listen 80;    server_name test.example.com;    root /var/www/api;     index index.php index.html index.htm index.nginx-debian.html;    location / {        proxy_pass             http://127.0.0.1:8000;        proxy_set_header Host  $host;        proxy_read_timeout     60;        proxy_connect_timeout  60;        proxy_redirect         off;        # Allow the use of websockets        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;    }     listen 443 ssl http2;     #ssl info removed}
查看完整描述

1 回答

?
慕桂英3389331

TA贡献2036条经验 获得超8个赞

经过一些错误和试验后,它的工作原理


server { 

listen 80;

server_name test.example.com; 


location / {

    proxy_pass             http://127.0.0.1:8000;

    proxy_set_header Host  $host;

    proxy_read_timeout     60;

    proxy_connect_timeout  60;

    proxy_redirect         off;


    # Allow the use of websockets

    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;


location /favicon.ico { alias /path/to/favicon.ico; }


listen 443 ssl http2; 

#ssl info removed

}

一些要点

  • 从服务器中删除根目录

  • 删除索引 {我们不需要索引,因为 ReactPhp 有自己的服务器}

  • 将proxy_pass端口与 ReactPhp 服务器端口匹配

  • 最好通过代理提供 SSL 与 nginx { 作为反应应用程序文档}

  • 502 网关错误 { 发生这种情况是因为我的服务器当时没有运行}


查看完整回答
反对 回复 2022-09-12
  • 1 回答
  • 0 关注
  • 79 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号