如何使用 ECS 集群内的 docker 重定向内部 URL 以尾随斜杠结尾 (ec2) [英] How to redirect internal URLs to end with trailing slashes with docker inside ECS cluster(ec2)

查看:16
本文介绍了如何使用 ECS 集群内的 docker 重定向内部 URL 以尾随斜杠结尾 (ec2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的前端网站托管在 AWS ECS 集群 (EC2) 的 docker 容器中.我想将我的内部页面重定向到末尾带有斜杠的页面.我想要的是即使 URL 被输入或定向到 https://us.springverify.com/api-integrations(不带斜杠)URL 应该重定向到 https://us.springverify.com/api-integrations/(带有斜杠).

I have my frontend website hosted in docker containers in AWS ECS cluster(EC2).I want to redirect my internal pages to pages with trailing slashes at the end. what i want is even if the URL is typed or directed to https://us.springverify.com/api-integrations (without a trailing slash) the URL should redirect to https://us.springverify.com/api-integrations/ (with trailing slashes).

我的设置 - Docker 容器-> EC2-> ECS-> 负载均衡器-> Route53.我的 Docker 文件.

My setup - Docker Containers->EC2->ECS->Load Balancer->Route53. My Docker File.

FROM node:8
WORKDIR /sv-us-frontend
COPY package.json /sv-us-frontend/package.json
RUN npm install
COPY . /sv-us-frontend
CMD ["npm", "run", "start"]
EXPOSE 4444 

推荐答案

遗憾的是,ALB 不支持 URL 重写或请求修改.您有以下选择来实现您想要的:

Unfortunately, ALB doesn't support URL rewriting or request modification. You have the following options to achieve what you want:

  1. 添加一个网络服务器,例如nginx 在您的服务/应用程序容器前面.然后就可以使用nginx来实现重写规则了.

  1. Add a webserver e.g. nginx in front of your services/application containers. Then you can use nginx to implement the rewrite rules.

在您的 ALB 前添加 CloudFront 分配并使用 CloudFront 函数重写 URL 如下所示.

Add a CloudFront distribution in front of your ALB and use the CloudFront Functions to rewrite the URL as shown here.

最好的,斯蒂芬

这篇关于如何使用 ECS 集群内的 docker 重定向内部 URL 以尾随斜杠结尾 (ec2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆