如何使用Apache反向代理跨域服务React应用程序



我有一个运行在http://160.119.253.70:3001在Docker中的React和Nginx上。

我有一个测试域和URL(Apache(:http://headlessway.capetown/reactllo

我希望在160.119机器上向.capetown/reactllo请求React应用程序。

我在开普敦的阿帕奇尝试:

<VirtualHost *:80>
RewriteEngine On
# RewriteCond %{HTTPS} on
# RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
ServerName headlessway.capetown
ServerAlias headlessway.capetown
ServerAdmin admin@headlessway.capetown
DocumentRoot /var/www/html/headlessway/

ProxyPassMatch ^/reactllo(.*)$  http://160.119.253.70:3001/$1
ProxyPass /reactllo http://160.119.253.70:3001/
RewriteRule    "^/home/.*$"  "http://headlessway.capetown"
RewriteRule "^/category/.*" "http://headlessway.capetown"
RewriteRule "^/author/.*" "http://headlessway.capetown"
</VirtualHost>

在160上。VPS我有这个NGINX:

server {
listen 80;
location / {
root   /usr/share/nginx/html;
index  index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}
}

我目前只得到一个空白页面,其中提供了原始HTML,而它在http://160.119.253.70:3001.

我意识到我的理解有很多差距——我只是一个业余爱好者,这是我第一次尝试JS网站。

我的路径是相对的,所以没有请求关键文件。愚蠢的问题:(每天都是上学的日子。

最新更新