使用axios代理槽OpenVPN在VUEJS中受保护的前端
希望你们都很好。
我面临着前端实例的问题。 实际上,我们有一个由OpenVPN凭据托管和确保的前端。这意味着,没有与我们的VPN连接的情况下没有人可以访问它。该配置效果很好,但Axios代理仍然存在一个问题。
快速注意:
- 我们不使用
- AWS CloudFront
- Backend托管的服务器端渲染前端部署到AWS EC2实例
中,这是我的Nuxtjs frontend中的当前配置nuxt.nuxt.config.js
file> file> file:
{
...,
proxy: {
'/api/': {
target: !process.env.FLAVOR
? 'http://localhost:8009'
: (process.env.FLAVOR === 'production'
? 'https://api.domain.tld'
: 'https://' + process.env.FLAVOR + '-api.domain.tld'),
pathRewrite: { '^/api/': '/v1/' }
}
},
...
}
此解决方案可帮助我轻松避免所有环境,而无需在Dockerfile中的环境变量以及CORS策略中设置每个URL。
这样,如果我检查控制台Inspector并验证网络选项卡,我将被拒绝,因为未连接到客户端。 VPN和代理如何真正起作用?请求称为客户端还是服务器端?
感谢您的帮助。
hope you are all good.
I'm facing an issue with my frontend instance.
Actually, we have a frontend hosted and secured by OpenVPN credentials. That means, no one can access it without a connection to our VPN. That configuration works well, but still one issue with axios proxies.
Quick notes:
- we are not using server-side rendering
- frontend hosted in AWS CloudFront
- backend deployed to AWS EC2 instances
This is the current configuration in my nuxtjs frontend nuxt.config.js
file:
{
...,
proxy: {
'/api/': {
target: !process.env.FLAVOR
? 'http://localhost:8009'
: (process.env.FLAVOR === 'production'
? 'https://api.domain.tld'
: 'https://' + process.env.FLAVOR + '-api.domain.tld'),
pathRewrite: { '^/api/': '/v1/' }
}
},
...
}
This solution helps me to avoid all environments easily, without setting each URL inside my environment variable in Dockerfile, and also the CORS policy.
In that way, if I check the console inspector and verify the network tab, I got access denied because not connected to the client. How do VPN and proxy really work? Are the requests called client-side or server-side?
Thanks by advance for helping me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论