簡體   English   中英

如何在我的 VPS nginx 中制作 axios url 點

[英]How to make axios url point in my VPS nginx

我第一次在具有新域的 VPS 中部署我的應用程序。 到目前為止,我的項目 axios url 是 'http://localhost:5000/posts' 我的節點服務器在 5000 端口中運行,我使用代理來響應監聽 5000 而不是 3000。

那么,我如何將這些網址傳輸到我的機器上? 我是否必須使用我的新服務器 IP 或 example.com 域到 axios Z572D4E421E5E6B7BEC18A0?

我能夠理解你想要反應和 nginx 應用程序在同一台服務器上運行在同一 IP 和你反應應用程序運行在 3000 端口和 nodejs 在 5000。

您可以在default.conf中進行以下配置

server {
  root /var/www/html;
  
  server_name _;
  listen 3000;

# this is the react application endpoints
  location / {
    try_files $uri $uri/ /index.html;
  }
}

在您的反應應用程序中,使用 api 端點作為http://127.0.0.1:5000/posts
所以現在,react 應用程序將由監聽 5000 的 nodejs 由 NGINX 和 api 處理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM