首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署在Ubunutu 18.04上的ReactPhp

部署在Ubunutu 18.04上的ReactPhp
EN

Stack Overflow用户
提问于 2020-02-07 14:17:07
回答 1查看 223关注 0票数 0

嗨,我在我的本地机器上有与ReactPHP一起工作的REST Api,我想把它部署在一个dev服务器上,

我在DO上添加了一个新的子域,使用nginx放置了一个conf,并为ReactPHP应用程序设置了一个正在进行的进程来php ReactPHP我的服务器根文件。

允许8000端口。

现在我无法访问api路由,我的服务器日志说Listening on tls://127.0.0.1:8000$loop->run();上的默认回显。

关于打子域的路线,它说

代码语言:javascript
复制
<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>

我的nginx conf

代码语言:javascript
复制
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
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-27 09:39:55

经过一些错误和试验使它起作用

代码语言:javascript
复制
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 { as ReactPhp Docs}

H 110502坏网关{这是因为我的服务器当时没有运行}H 211F 212

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60115197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档