Reactjs 为什么AWS PVCs中的Nginx config指向我的本地主机而不是AWS PVCs中的本地主机?
我使用Centos7在AWS PVCs中托管ReactJS应用程序和ExpressJS,并使用Nginx为ReactJS构建文件提供服务Reactjs 为什么AWS PVCs中的Nginx config指向我的本地主机而不是AWS PVCs中的本地主机?,reactjs,express,nginx,amazon-ec2,centos,Reactjs,Express,Nginx,Amazon Ec2,Centos,我使用Centos7在AWS PVCs中托管ReactJS应用程序和ExpressJS,并使用Nginx为ReactJS构建文件提供服务 ExpressJS的应用程序正在端口5000上运行 ReactJS的应用程序正在端口80上运行 下面是我的配置 user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /us
- ExpressJS的应用程序正在端口5000上运行
- ReactJS的应用程序正在端口80上运行
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:5000;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
当我试图访问端口80上的ReactJS应用程序时,它总是被请求到本地主机
如果我关闭笔记本电脑上的本地服务器,我会收到一条错误消息说CORS失败。
如果我打开笔记本电脑上的本地服务器,ReactJS应用程序将成功加载。
我是否遗漏了Nginx配置中的某些内容?因此它从未在AWS PVCs服务器中读取本地主机?