Skip to content

Instantly share code, notes, and snippets.

@manish-2014
Created November 17, 2020 17:13
Show Gist options
  • Save manish-2014/ff9c2ff658d7613626e078ebe225072d to your computer and use it in GitHub Desktop.
Save manish-2014/ff9c2ff658d7613626e078ebe225072d to your computer and use it in GitHub Desktop.
Setting up NGINX reverse proxy for shadow-cljs development
; project.clj
:devtools {:http-root "resources/public"
:http-port 8281
:devtools-url "https://localqa1.myserver.com/shadow-cljs"
:use-document-protocol true
}}}}
; assuming you already have a sites-available file for localqa1.myserver.com
;localqa1.myserver.com
; add this
; this serves shadow-cljs websockets
location /shadow-cljs/ {
proxy_pass http://localhost:9630/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
; I copied it from here :https://gist.github.com/theasp/92b36733846be7dc0ed78840d3a3515a
; this serves your static assets including your app.js from the shadow-cljs http server
location /cljsapps/ {
# matches any query beginning with /images/ and halts searching,
# so regular expressions will not be checked.
proxy_pass http://localhost:8281/;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
# Allow websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Standard proxy headers
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering on;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
gzip_proxied any;
}
@andyfry01
Copy link

After a long sweaty internet journey to figure out how to develop a shadow-cljs app on a VM, REPL and all, this gist was the thing I was looking for.

Thanks for posting it! Huge help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment