next -mail在使用nginx反向代理时出现504失败



我将next -mail配置为从我们的next应用程序发送电子邮件。我的应用程序的baseURL改为"https://localhost:3000/app"而不是"https://localhost:3000"因此,nginx将所有对'/'的调用重定向到静态应用程序,并将所有对'/app'的调用重定向到动态应用程序。问题是,在生产中,next -mail无法通过post发送电子邮件到'/app/mail/send'。

  1. 我尝试在nuext .config.js上设置axios baseURL,正如npm/github页面
  2. 中建议的那样
  3. 我没有看到发送的路径邮件或.nuxt/router.js

文件:contact.vue注意:WEBSITE_DOMAIN指向https://localhost:3000本地有效的web域,格式如下:https://www.production_website.com

<script>
...
methods: {
...
sendMail(){
this.$axios.post( 
this.$config.WEBSITE_DOMAIN+'/app/mail/send', 
{
...
}
...
}
...
</script>

文件:nuxt.config.js

...
export default{
...
router: {
base: '/app/'
},
...
}

注意:我确实配置了从nginx到应用服务器的上游日志

nginx在生产环境中的访问日志

49.205.150.249 - - [04/May/20122:15:30:54 +0000] "POST/app/mail/send HTTP/1.1"504 167 "https://www..com/app/contact"Mozilla/5.0 (X11;Ubuntu;Linux x86_64;房车:99.0)壁虎/20100101Firefox/99.0">

nginx的错误日志

2022/05/04 15:30:54 [error] 2106#2106: *38 upstream timed out (110:连接超时)从上游读取响应头时,客户端:49.205.150.249,服务器:.com,请求:"POST/app/mail/send HTTP/1.1"https:// .com"引用:"https://www.<xxxxxxxxx_NAME> .com/app/contact"

我在这里错过了什么?不过它在我的舞台上运行得很好。

生产实例上允许SMTP的端口未打开。在AWS EC2上,我需要在相应的安全组上启用出站规则。

最新更新