I'm setting up a service that returns a JSON, thanks to Ring, Compojure and Jetty. The problem I have is when I want to use Nginx as a reverse proxy. If I use the following handlers it doesn't work.
(def wrapped-handler
;; Handler middlewares
(-> all-routes
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
wrap-params
wrap-session
))
The message I get back is
java.lang.NullPointerException
at ring.adapter.jetty$proxy_handler$fn__6990.invoke(jetty.clj:26)
at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:503)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.base/java.lang.Thread.run(Thread.java:834)
But if I add wrap-reload everything goes right.
(def wrapped-handler
;; Handler middlewares
(-> all-routes
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
wrap-params
wrap-session
(#(if (config :debug) (wrap-reload %)))
))
My setup with Nginx is as follows.
server {
server_name domain.com;
location / {
proxy_pass http://localhost:9000/;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
Is it safe to leave wrap-reload in production?
What have I left behind?
Thank you all in advance.