【发布时间】:2022-01-06 09:06:37
【问题描述】:
我想让我的网站在没有端口 3000 的域上可用,我知道 React JS 和 Nginx 不能使用相同的端口,所以下面你可以看到我的 Nginx 文件的配置:
location / {
# try_files $uri $uri.html $uri/ @extensionless-php;
proxy_set_header Accept-Encoding "";
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;
}
location /static/ {
proxy_set_header Accept-Encoding "";
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;
}
当我转到 https://example.com 时,我在控制台中看到一个空白页和以下错误: Image
但是当我转到 http://example.com:3000 时,一切正常,没有任何问题,那么我怎样才能让它在 https://example.com 上运行?
【问题讨论】:
标签: javascript reactjs ubuntu nginx