【问题标题】:having trouble with ports and deploying react/node project to digital ocean遇到端口问题并将反应/节点项目部署到数字海洋
【发布时间】:2018-12-08 00:42:25
【问题描述】:

我尝试将我的项目部署到 Digital Ocean。

有一次,当我转到 my_ip:8080 时,我能够看到我的 react 客户端,无论出于何种原因,它都是在其上运行的端口。

我设置了 SSL,然后cd etc/nginx/sites-enabled 点击 vim 默认并开始编辑。这是我开始遇到问题的地方,我的 react 项目停止出现的地方,以及最终我被卡住的地方。

所以这就是该文件中的内容

server {

    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    listen 80;
    server_name my_website.com;
    rewrite ^/a(.*) https://my_website.com/$1 permanent;

    location / {
    proxy_pass http://localhost:8080;
    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;
}


    root /var/www/client/build;

    index index.html index.htm index.nginx-debian.html;

    server_name my_website.com;
    ssl_certificate /root/my_website.crt;
    ssl_certificate_key /root/my_website.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

    location / {

    }

但显然有些东西在这里不起作用。

如果我执行pm2 list,它将显示index 在0 上运行,status: onlinestatic-page-server-8080 在 1 上运行,但status: errored

我尝试设置 ufw,但我什至不确定这是否搞砸了。

所以目前如果我在浏览器中访问我的 IP,我什么也得不到。如果我在最后添加一个端口,我什么也得不到。我应该如何解决这个问题?我应该把它报废再试一次吗?

【问题讨论】:

    标签: node.js reactjs deployment digital-ocean


    【解决方案1】:

    阅读文档here。对于 SSL,this 很有用。

    作为健全性检查,我还建议:

    1. 停止您在pm2 list 中看到的所有运行。
    2. 直接在终端的 8080 端口上启动您的项目并尝试从浏览器访问它。
    3. 这将告诉您是否是您的代码、pm2 或您如何设置 nginx 的问题。

    另外,这就是我的配置如下所示。你是 localhost 可能不应该被注释掉。

    服务器{ server_name www.foo.com foo.com;

    location / {
        proxy_pass http://localhost:3000;
        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; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/foo.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/foo.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    

    }

    【讨论】:

    • 好的,我已经让我的客户显示在我的根 URL 上。我现在的问题是我在哪里设置我的服务器运行?这可能是我的一些基本误解,但我很好奇我究竟在哪里安装服务器以及如何从我的前端客户端访问它?
    猜你喜欢
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 2017-12-12
    • 2016-05-30
    • 2018-10-31
    • 2016-07-22
    • 1970-01-01
    相关资源
    最近更新 更多