Skip to content

Commit 39975f3

Browse files
committed
init commit of production machine state
0 parents  commit 39975f3

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

TODO.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Full server config
2+
- How to open ports
3+
- Add todos!

apps.jsbin.com/WWW/jsbin/run.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require('nodetime').profile({
2+
accountKey: '<TODO-PUT-IN-CONFIG>',
3+
appName: 'jsbin.com'
4+
});
5+
6+
var jsbin = require('./lib/app');
7+
var gzippo = require('gzippo');
8+
var fs = require('fs');
9+
10+
jsbin.use(gzippo.compress());
11+
12+
jsbin.on('before', function () {
13+
jsbin.use(function (req, res, next) {
14+
// if (req.ip == '93.97.184.95') stream.write(req.originalUrl + '\n');
15+
16+
var v3betaurl = jsbin.set('url prefix') + '/3/',
17+
host = req.header('host', '');
18+
19+
if (req.url.indexOf(v3betaurl) === 0) {
20+
res.redirect(301, req.url.substring(v3betaurl.length - 1));
21+
} else if (host.indexOf('www') === 0 || host.indexOf('3.') === 0 || host.indexOf('apps.') === 0) {
22+
res.redirect(301, jsbin.set('url full') + req.url);
23+
} else {
24+
next();
25+
}
26+
});
27+
});
28+
29+
jsbin.connect();

apps.jsbin.com/etc/nginx/nginx.conf

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
user www-data;
2+
worker_processes 4;
3+
pid /var/run/nginx.pid;
4+
5+
events {
6+
worker_connections 768;
7+
# multi_accept on;
8+
# debug_connection 93.97.184.95;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
server_tokens off;
15+
16+
sendfile on;
17+
tcp_nopush on;
18+
tcp_nodelay on;
19+
20+
keepalive_timeout 20;
21+
22+
gzip on;
23+
gzip_http_version 1.0;
24+
gzip_comp_level 5;
25+
gzip_min_length 256;
26+
gzip_disable msie6;
27+
gzip_proxied any;
28+
gzip_vary on;
29+
gzip_types
30+
application/atom+xml
31+
application/javascript
32+
application/x-javascript
33+
application/json
34+
application/rss+xml
35+
application/vnd.ms-fontobject
36+
application/x-font-ttf
37+
application/x-web-app-manifest+json
38+
application/xhtml+xml
39+
application/xml
40+
font/opentype
41+
image/svg+xml
42+
image/x-icon
43+
text/css
44+
text/plain
45+
text/x-component;
46+
47+
48+
# Redirect https to http to fix cached issue in jsbin visitor's browser
49+
server {
50+
listen 443;
51+
ssl on;
52+
ssl_certificate /WWW/jsbin/jsbin.crt;
53+
ssl_certificate_key /WWW/jsbin/jsbin.key;
54+
55+
ssl_session_timeout 5m;
56+
57+
ssl_protocols SSLv2 SSLv3 TLSv1;
58+
ssl_ciphers HIGH:!aNULL:!MD5;
59+
ssl_prefer_server_ciphers on;
60+
61+
return 301 http://$host$request_uri;
62+
}
63+
64+
# static.jsbin.com : static server
65+
server {
66+
listen 80;
67+
server_name static.jsbin.com;
68+
root /WWW/jsbin/public/;
69+
index index.html;
70+
access_log /var/log/nginx/static.jsbin.com.log;
71+
72+
# Expire rules for static content
73+
74+
# cache.appcache, your document html and data
75+
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
76+
expires -1;
77+
}
78+
79+
# Media: images, icons, video, audio, HTC
80+
location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
81+
expires 1M;
82+
access_log off;
83+
add_header Cache-Control "public";
84+
}
85+
86+
# CSS and Javascript
87+
location ~* \.(?:css|js)$ {
88+
expires 1y;
89+
access_log off;
90+
add_header Cache-Control "public";
91+
}
92+
93+
# WebFonts
94+
location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
95+
expires 1M;
96+
access_log off;
97+
add_header Cache-Control "public";
98+
}
99+
100+
# Try to serve the files, or serve a 404
101+
location / {
102+
try_files $uri $uri/ =404;
103+
# Cache hard
104+
add_header Pragma "public";
105+
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
106+
add_header Last-Modified $sent_http_Expires;
107+
add_header Access-Control-Allow-Origin *;
108+
}
109+
}
110+
111+
# jsbin.com : proxy port 80 traffic to Node
112+
server {
113+
listen 80 default_server;
114+
server_name _;
115+
# jsbin.com run.jsbin.com www.jsbin.com 3.jsbin.com;
116+
access_log /var/log/nginx/jsbin.log;
117+
118+
location / {
119+
# Pass the request on to Node.
120+
proxy_pass http://localhost:8000;
121+
122+
# Pass a bunch of headers to the downstream server, so they'll know what's going on.
123+
proxy_set_header Host $host;
124+
proxy_set_header X-Real-IP $remote_addr;
125+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
126+
proxy_set_header X-Accel-Buffering no;
127+
proxy_set_header Connection '';
128+
129+
proxy_http_version 1.1;
130+
proxy_buffering off;
131+
proxy_cache off;
132+
proxy_redirect off;
133+
}
134+
}
135+
}

0 commit comments

Comments
 (0)