Skip to content

Commit

Permalink
Support gcloud uploads and improve redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoore committed Jul 16, 2016
1 parent 0c3afd5 commit 157e0db
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ npm-debug.log
.git
.hg
.svn
packagejson/docker
packagejson/gcloud
vendor
/packagejson/docker
/packagejson/gcloud
/vendor
app.yaml
app.*.yaml
.gitignore
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
npm-debug.log
vendor
/vendor
app.*.yaml

1 change: 1 addition & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ env_variables:
GAE_NODEBB_CONFIG_METADATA_KEY:
PORT_NODEBB: 4567
IS_APP_ENGINE: true
GCLOUD_BUCKET_SUFFIX:
2 changes: 1 addition & 1 deletion packagejson/gcloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"":""
, "deploy.dev": "(cd ../.. && gcloud preview app deploy app.dev.yaml)"
, "deploy.prod": "(cd ../.. && gcloud preview app deploy app.prod.yaml)"
, "deploy.prod": "(cd ../.. && gcloud preview app deploy app.prod.yaml --verbosity debug)"
, "setup.firewall": "gcloud compute --project 'space-hq' firewall-rules create 'nodebb-allow-websocket' --allow tcp:$PORT_NODEBB --description 'nodebb/socket.io/engine.io benefits from websockets' --network 'default' --source-ranges '0.0.0.0/0' --target-tags 'websocketed'"

}
Expand Down
3 changes: 2 additions & 1 deletion packagejson/nodebb/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"scripts": {
"":""
, "prep": "mkdir -p ../../vendor/nodebb && npm run gather && npm run pare && npm run api"
, "prep": "mkdir -p ../../vendor/nodebb && npm run gather && npm run pare && npm run api && npm run gcs"
, "gather": "curl -L https://github.com/NodeBB/NodeBB/archive/v1.0.3.tar.gz | tar -xz -C ../../vendor/nodebb --strip 1"
, "pare": "(cd ../../vendor/nodebb && (npm install --unsafe-perm || ((if [ -f npm-debug.log ]; then cat npm-debug.log; fi) && false)))"
, "api": "(cd ../../vendor/nodebb && (npm install --unsafe-perm nodebb-plugin-write-api))"
, "gcs": "(cd ../../vendor/nodebb && (npm install --unsafe-perm jcmoore/nodebb-plugin-gcloud-storage-uploads#3870cf729f0e1d1e944904699a33eda8e4775562))"

}
}
15 changes: 11 additions & 4 deletions src/nodebb-bubble-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,23 @@ var server = http.createServer(function(req, res) {
var pathify = (req.headers["x-pathify-query"] || "").trim();

if (req.url.indexOf("/_ah/") === 0) {
res.writeHead(404, {});
return res.end("");
if (req.url === "/_ah/health" ||
req.url === "/_ah/health/") {
return proxy.web(req, res, {
target: hostSpeak+"/api/",
});
} else {
res.writeHead(404, {});
return res.end("");
}
} else if (pathify) {
target += rewriteRequestPathUsingQueryParams(req.url, pathify.split(/\s*,\s*/g));
} else if (req.url.indexOf("/api/") !== 0) {
} else if (req.url.search(/^\/(api|uploads)\//) !== 0) {
if (endpoint &&
(req.headers.host || "").split(dot).length < 4) {
// redirect
res.writeHead(301, {
Location: endpoint
Location: endpoint+req.url,
});

return res.end();
Expand Down

0 comments on commit 157e0db

Please sign in to comment.