阻止具有原始EC2 URL的框架访问具有原始DOMAIN URL的框架。协议,域和端口必须匹配[关闭]

问题描述 投票:0回答:1

正在做什么

我已启动MERN堆栈仪表板并在AWS EC2实例上运行。

  • Ec2实例位于ec2 ... aws.com
  • React应用程序通过端口5004提供。
  • 节点应用程序正在端口5003上运行。

更改内容

当我在GoDaddy设置要转发的域(带有屏蔽)时,问题开始了从somebusiness.comec2 ..... aws.com

首先,我设置NGINX反向代理以将/作为我的React应用(前端),将/ api作为我的节点应用(后端)((稍后您会在下面找到Nginx代码)

[http://somebusiness.com/ 工作正常http://somebusiness.com/api/heartbeat

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <title>Somebusiness Dashboard</title>
  <meta name="description" content="">
  <meta name="keywords" content="">
</head>
<frameset rows="100%,*" border="0">
  <frame src="http://ec2-...aws.com/api/heartbeat" frameborder="0" />
</frameset>

</html>

框架中的实际URL是可以正常工作的URL:http://ec2-...aws.com/api/heartbeat 工作正常

我认为GoDaddy与此有关,因为在GoDaddy上,我可以为此转发指定标题,描述和关键字。因此,作为后端,我被迫使用http://ec2-...aws.com/api/作为我的后端URL,这现在还可以(由于是域名,因此也很方便,目前是我的[[secondary problem)

主要问题

我在Mozilla和Safari的浏览器控制台中遇到以下问题:

[阻止原点为[http://ec2...aws.com]的帧访问原点为“ http://somebusiness.com”的帧。协议,域和端口必须匹配。

正如我在网络上研究的那样,是一种安全措施,我找不到禁用或解决该问题的方法。处理此问题的最佳方法是什么。

帮助的源代码

因为我使用的是

Amazon Linux 2],所以我使用了它的工具来安装nginx1和设置反向代理。当我在其他VPS上使用NGINX时,其结构有所不同(启用站点和可用站点的文件夹)。但是在此nginx上,只有nginx.conf文件可以在其中进行设置。 (我想这没什么区别,只想注意一下)

# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ 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 eyeratereviews.com; root /home/ec2-user/somebusiness-web-backend; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; include /etc/nginx/mime.types; location / { proxy_pass http://127.0.0.1:5004; 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 /api/ { root /home/ec2-user/somebusiness-web-backend/uploads/avatars; default_type application/json; proxy_pass http://127.0.0.1:5003/; # Following is necessary for Websocket support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
正在做什么,我已经安装了MERN堆栈仪表板并在AWS EC2实例上运行。 ec2实例位于ec2 ... aws.com上,React应用程序在端口5004上运行。Node app在端口5003上运行。什么是...
amazon-web-services nginx amazon-ec2 mern
1个回答
0
投票
设置SSL证书后,问题消失了。
© www.soinside.com 2019 - 2024. All rights reserved.