Nginx后面的HTTPS上的Moqui连接被拒绝

时间:2019-05-19 19:26:59

标签: postgresql nginx https amazon-elastic-beanstalk moqui

post是指。

好的,我花了最后两天的时间来尝试获取ebextensions配置,以便通过创建LetsEncrypt证书在Nginx上为单个EC2实例配置HTTPS加密。一切似乎都根据日志进行(一旦工作完全,它将在其他帖子上发布配置)。但是,当尝试通过HTTPS访问Moqui时,出现了一些奇怪的行为。 HTTP可以正常工作,但是一旦我切换到HTTPS,就会拒绝更正。我从EB日志中得到了以下信息:

/var/log/web-1.log
-------------------------------------
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.recover(XaResourceRecoveryManager.java:67) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:451) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.performRecovery(TransactionServiceImp.java:490) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.access$000(TransactionServiceImp.java:56) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp$1.alarm(TransactionServiceImp.java:471) [transactions-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95) [atomikos-util-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82) [atomikos-util-4.0.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.createStatement(AbstractJdbc3Connection.java:231) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.createStatement(AbstractJdbc2Connection.java:310) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:341) ~[postgresql-9.3-1102.jdbc41.jar:?]
    ... 12 more
[33m18:36:04.327  WARN   Atomikos:1 atomikos.r.x.XaResourceRecoveryManager[m Error while retrieving xids from resource - will retry later...
org.postgresql.xa.PGXAException: Error during recover
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:368) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at com.atomikos.datasource.xa.RecoveryScan.recoverXids(RecoveryScan.java:32) ~[transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.retrievePreparedXidsFromXaResource(XaResourceRecoveryManager.java:158) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.recover(XaResourceRecoveryManager.java:67) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:451) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.performRecovery(TransactionServiceImp.java:490) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.access$000(TransactionServiceImp.java:56) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp$1.alarm(TransactionServiceImp.java:471) [transactions-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95) [atomikos-util-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82) [atomikos-util-4.0.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.createStatement(AbstractJdbc3Connection.java:231) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.createStatement(AbstractJdbc2Connection.java:310) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:341) ~[postgresql-9.3-1102.jdbc41.jar:?]
    ... 12 more
[33m18:36:14.327  WARN   Atomikos:1 atomikos.r.x.XaResourceRecoveryManager[m Error while retrieving xids from resource - will retry later...
org.postgresql.xa.PGXAException: Error during recover
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:368) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at com.atomikos.datasource.xa.RecoveryScan.recoverXids(RecoveryScan.java:32) ~[transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.retrievePreparedXidsFromXaResource(XaResourceRecoveryManager.java:158) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.recover(XaResourceRecoveryManager.java:67) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:451) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.performRecovery(TransactionServiceImp.java:490) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.access$000(TransactionServiceImp.java:56) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp$1.alarm(TransactionServiceImp.java:471) [transactions-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95) [atomikos-util-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82) [atomikos-util-4.0.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.createStatement(AbstractJdbc3Connection.java:231) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.createStatement(AbstractJdbc2Connection.java:310) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:341) ~[postgresql-9.3-1102.jdbc41.jar:?]
    ... 12 more
[33m18:36:24.328  WARN   Atomikos:1 atomikos.r.x.XaResourceRecoveryManager[m Error while retrieving xids from resource - will retry later...
org.postgresql.xa.PGXAException: Error during recover
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:368) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at com.atomikos.datasource.xa.RecoveryScan.recoverXids(RecoveryScan.java:32) ~[transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.retrievePreparedXidsFromXaResource(XaResourceRecoveryManager.java:158) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.recover(XaResourceRecoveryManager.java:67) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:451) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.performRecovery(TransactionServiceImp.java:490) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.access$000(TransactionServiceImp.java:56) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp$1.alarm(TransactionServiceImp.java:471) [transactions-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95) [atomikos-util-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82) [atomikos-util-4.0.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.createStatement(AbstractJdbc3Connection.java:231) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.createStatement(AbstractJdbc2Connection.java:310) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:341) ~[postgresql-9.3-1102.jdbc41.jar:?]
    ... 12 more
[33m18:36:34.328  WARN   Atomikos:1 atomikos.r.x.XaResourceRecoveryManager[m Error while retrieving xids from resource - will retry later...
org.postgresql.xa.PGXAException: Error during recover
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:368) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at com.atomikos.datasource.xa.RecoveryScan.recoverXids(RecoveryScan.java:32) ~[transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.retrievePreparedXidsFromXaResource(XaResourceRecoveryManager.java:158) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.recovery.xa.XaResourceRecoveryManager.recover(XaResourceRecoveryManager.java:67) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.datasource.xa.XATransactionalResource.recover(XATransactionalResource.java:451) [transactions-jta-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.performRecovery(TransactionServiceImp.java:490) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp.access$000(TransactionServiceImp.java:56) [transactions-4.0.4.jar:?]
    at com.atomikos.icatch.imp.TransactionServiceImp$1.alarm(TransactionServiceImp.java:471) [transactions-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95) [atomikos-util-4.0.4.jar:?]
    at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82) [atomikos-util-4.0.4.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
    at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:843) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.createStatement(AbstractJdbc3Connection.java:231) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.createStatement(AbstractJdbc2Connection.java:310) ~[postgresql-9.3-1102.jdbc41.jar:?]
    at org.postgresql.xa.PGXAConnection.recover(PGXAConnection.java:341) ~[postgresql-9.3-1102.jdbc41.jar:?]
    ... 12 more

/var/log/nginx/error.log 为空,这显然是Moqui异常,因此Nginx大概可以正确接收流量。似乎是Postgres的根本原因,但是正如我说的那样,我可以通过HTTP来访问所有内容,因此当请求通过HTTPS发出时,Moqui中的Postgres连接似乎已关闭,这似乎不太可能。

将感谢您的任何帮助,以便我能弄清楚如何在单个EC2实例上部署Moqui。将在另一篇文章中分享解决方案。

2 个答案:

答案 0 :(得分:0)

一种方法是在Tomcat /etc/tomcat7/server.xml中创建一个阀门:

val src = io.Source.fromFile("so.txt")

"(?s)>\\s*(.+?)(?=\n\n|$)".r
                          .findAllMatchIn(src.mkString)
                          .map(_.group(1))
                          .mkString("->", "<-\n->", "<-")
//res0: String =
//->col1 col2 col3
//1 2 3
//4 5 6
//helo how are <-
//->col1 col2
//1 2
//helo hi'<-

src.close()

在您的nginx设置中使用类似以下的内容。

     <Valve className="org.apache.catalina.valves.RemoteIpValve"
            internalProxies=".*"
            remoteIpHeader="x-forwarded-for"
            remoteIpProxiesHeader="x-forwarded-by"
            protocolHeader="x-forwarded-proto" />

答案 1 :(得分:0)

忽略此白痴。问题是Nginx在Elastic Beanstalk上不接受我的自定义Nginx配置作为独立Java SE实例,因此端口443从来没有正确设置。仍然无法弄清楚为什么我要恢复该日志信息,因为如果关闭了端口443,该请求将永远不会到达Moqui。

无论如何,我几乎设法使配置完全正常运行。完成后将在这里更新。