Skip to content

Commit 562af66

Browse files
committed
[nginx mode] Integrate
1 parent ad333b6 commit 562af66

File tree

5 files changed

+134
-131
lines changed

5 files changed

+134
-131
lines changed

doc/compress.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
101101
<option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
102102
<option value="http://codemirror.net/mode/markdown/markdown.js">markdown.js</option>
103103
<option value="http://codemirror.net/mode/mirc/mirc.js">mirc.js</option>
104+
<option value="http://codemirror.net/mode/nginx/nginx.js">ntriples.js</option>
104105
<option value="http://codemirror.net/mode/ntriples/ntriples.js">ntriples.js</option>
105106
<option value="http://codemirror.net/mode/ocaml/ocaml.js">ocaml.js</option>
106107
<option value="http://codemirror.net/mode/pascal/pascal.js">pascal.js</option>

doc/modes.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
5454
<li><a href="../mode/lua/index.html">Lua</a></li>
5555
<li><a href="../mode/markdown/index.html">Markdown</a> (<a href="../mode/gfm/index.html">GitHub-flavour</a>)</li>
5656
<li><a href="../mode/mirc/index.html">mIRC</a></li>
57+
<li><a href="../mode/nginx/index.html">Nginx</a></li>
5758
<li><a href="../mode/ntriples/index.html">NTriples</a></li>
5859
<li><a href="../mode/ocaml/index.html">OCaml</a></li>
5960
<li><a href="../mode/pascal/index.html">Pascal</a></li>

mode/meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CodeMirror.modeInfo = [
3737
{name: 'Lua', mime: 'text/x-lua', mode: 'lua'},
3838
{name: 'Markdown (GitHub-flavour)', mime: 'text/x-markdown', mode: 'markdown'},
3939
{name: 'mIRC', mime: 'text/mirc', mode: 'mirc'},
40+
{name: 'Nginx', mime: 'text/x-nginx-conf', mode: 'nginx'},
4041
{name: 'NTriples', mime: 'text/n-triples', mode: 'ntriples'},
4142
{name: 'OCaml', mime: 'text/x-ocaml', mode: 'ocaml'},
4243
{name: 'Pascal', mime: 'text/x-pascal', mode: 'pascal'},

mode/nginx/index.html

Lines changed: 129 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -8,155 +8,154 @@
88
<style>.CodeMirror {background: #f8f8f8;}</style>
99
<link rel="stylesheet" href="../../doc/docs.css">
1010
</head>
11-
11+
1212
<style>
1313
body {
1414
margin: 0em auto;
1515
}
16-
16+
1717
.CodeMirror, .CodeMirror-scroll {
1818
height: 600px;
1919
}
2020
</style>
21-
21+
2222
<body>
2323
<h1>CodeMirror: NGINX mode</h1>
2424
<form><textarea id="code" name="code" style="height: 800px;">
25-
server {
26-
listen 173.255.219.235:80;
27-
server_name website.com.au;
28-
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
25+
server {
26+
listen 173.255.219.235:80;
27+
server_name website.com.au;
28+
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
2929
}
3030

3131
server {
32-
listen 173.255.219.235:443;
33-
server_name website.com.au;
34-
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
32+
listen 173.255.219.235:443;
33+
server_name website.com.au;
34+
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
3535
}
3636

3737
server {
38-
39-
listen 173.255.219.235:80;
40-
server_name www.website.com.au;
41-
42-
43-
44-
root /data/www;
45-
index index.html index.php;
46-
47-
location / {
48-
index index.html index.php; ## Allow a static html file to be shown first
49-
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
50-
expires 30d; ## Assume all files are cachable
51-
}
52-
53-
## These locations would be hidden by .htaccess normally
54-
location /app/ { deny all; }
55-
location /includes/ { deny all; }
56-
location /lib/ { deny all; }
57-
location /media/downloadable/ { deny all; }
58-
location /pkginfo/ { deny all; }
59-
location /report/config.xml { deny all; }
60-
location /var/ { deny all; }
61-
62-
location /var/export/ { ## Allow admins only to view export folder
63-
auth_basic "Restricted"; ## Message shown in login window
64-
auth_basic_user_file /rs/passwords/testfile; ## See /etc/nginx/htpassword
65-
autoindex on;
66-
}
67-
68-
location /. { ## Disable .htaccess and other hidden files
69-
return 404;
70-
}
71-
72-
location @handler { ## Magento uses a common front handler
73-
rewrite / /index.php;
74-
}
75-
76-
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
77-
rewrite ^/(.*.php)/ /$1 last;
78-
}
79-
80-
location ~ \.php$ {
81-
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
82-
83-
fastcgi_pass 127.0.0.1:9000;
84-
fastcgi_index index.php;
85-
fastcgi_param PATH_INFO $fastcgi_script_name;
86-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
87-
include /rs/confs/nginx/fastcgi_params;
88-
}
89-
38+
39+
listen 173.255.219.235:80;
40+
server_name www.website.com.au;
41+
42+
43+
44+
root /data/www;
45+
index index.html index.php;
46+
47+
location / {
48+
index index.html index.php; ## Allow a static html file to be shown first
49+
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
50+
expires 30d; ## Assume all files are cachable
51+
}
52+
53+
## These locations would be hidden by .htaccess normally
54+
location /app/ { deny all; }
55+
location /includes/ { deny all; }
56+
location /lib/ { deny all; }
57+
location /media/downloadable/ { deny all; }
58+
location /pkginfo/ { deny all; }
59+
location /report/config.xml { deny all; }
60+
location /var/ { deny all; }
61+
62+
location /var/export/ { ## Allow admins only to view export folder
63+
auth_basic "Restricted"; ## Message shown in login window
64+
auth_basic_user_file /rs/passwords/testfile; ## See /etc/nginx/htpassword
65+
autoindex on;
9066
}
91-
92-
93-
server {
94-
95-
listen 173.255.219.235:443;
96-
server_name website.com.au www.website.com.au;
97-
98-
root /data/www;
99-
index index.html index.php;
100-
101-
ssl on;
102-
ssl_certificate /rs/ssl/ssl.crt;
103-
ssl_certificate_key /rs/ssl/ssl.key;
104-
105-
ssl_session_timeout 5m;
106-
107-
ssl_protocols SSLv2 SSLv3 TLSv1;
108-
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
109-
ssl_prefer_server_ciphers on;
110-
111-
112-
113-
location / {
114-
index index.html index.php; ## Allow a static html file to be shown first
115-
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
116-
expires 30d; ## Assume all files are cachable
117-
}
118-
119-
## These locations would be hidden by .htaccess normally
120-
location /app/ { deny all; }
121-
location /includes/ { deny all; }
122-
location /lib/ { deny all; }
123-
location /media/downloadable/ { deny all; }
124-
location /pkginfo/ { deny all; }
125-
location /report/config.xml { deny all; }
126-
location /var/ { deny all; }
127-
128-
location /var/export/ { ## Allow admins only to view export folder
129-
auth_basic "Restricted"; ## Message shown in login window
130-
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
131-
autoindex on;
132-
}
133-
134-
location /. { ## Disable .htaccess and other hidden files
135-
return 404;
136-
}
137-
138-
location @handler { ## Magento uses a common front handler
139-
rewrite / /index.php;
140-
}
141-
142-
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
143-
rewrite ^/(.*.php)/ /$1 last;
144-
}
145-
146-
location ~ .php$ { ## Execute PHP scripts
147-
if (!-e $request_filename) { rewrite /index.php last; } ## Catch 404s that try_files miss
148-
149-
fastcgi_pass 127.0.0.1:9000;
150-
fastcgi_index index.php;
151-
fastcgi_param PATH_INFO $fastcgi_script_name;
152-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
153-
include /rs/confs/nginx/fastcgi_params;
154-
155-
fastcgi_param HTTPS on;
156-
}
157-
158-
}
15967

68+
location /. { ## Disable .htaccess and other hidden files
69+
return 404;
70+
}
71+
72+
location @handler { ## Magento uses a common front handler
73+
rewrite / /index.php;
74+
}
75+
76+
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
77+
rewrite ^/(.*.php)/ /$1 last;
78+
}
79+
80+
location ~ \.php$ {
81+
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
82+
83+
fastcgi_pass 127.0.0.1:9000;
84+
fastcgi_index index.php;
85+
fastcgi_param PATH_INFO $fastcgi_script_name;
86+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
87+
include /rs/confs/nginx/fastcgi_params;
88+
}
89+
90+
}
91+
92+
93+
server {
94+
95+
listen 173.255.219.235:443;
96+
server_name website.com.au www.website.com.au;
97+
98+
root /data/www;
99+
index index.html index.php;
100+
101+
ssl on;
102+
ssl_certificate /rs/ssl/ssl.crt;
103+
ssl_certificate_key /rs/ssl/ssl.key;
104+
105+
ssl_session_timeout 5m;
106+
107+
ssl_protocols SSLv2 SSLv3 TLSv1;
108+
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
109+
ssl_prefer_server_ciphers on;
110+
111+
112+
113+
location / {
114+
index index.html index.php; ## Allow a static html file to be shown first
115+
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
116+
expires 30d; ## Assume all files are cachable
117+
}
118+
119+
## These locations would be hidden by .htaccess normally
120+
location /app/ { deny all; }
121+
location /includes/ { deny all; }
122+
location /lib/ { deny all; }
123+
location /media/downloadable/ { deny all; }
124+
location /pkginfo/ { deny all; }
125+
location /report/config.xml { deny all; }
126+
location /var/ { deny all; }
127+
128+
location /var/export/ { ## Allow admins only to view export folder
129+
auth_basic "Restricted"; ## Message shown in login window
130+
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
131+
autoindex on;
132+
}
133+
134+
location /. { ## Disable .htaccess and other hidden files
135+
return 404;
136+
}
137+
138+
location @handler { ## Magento uses a common front handler
139+
rewrite / /index.php;
140+
}
141+
142+
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
143+
rewrite ^/(.*.php)/ /$1 last;
144+
}
145+
146+
location ~ .php$ { ## Execute PHP scripts
147+
if (!-e $request_filename) { rewrite /index.php last; } ## Catch 404s that try_files miss
148+
149+
fastcgi_pass 127.0.0.1:9000;
150+
fastcgi_index index.php;
151+
fastcgi_param PATH_INFO $fastcgi_script_name;
152+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
153+
include /rs/confs/nginx/fastcgi_params;
154+
155+
fastcgi_param HTTPS on;
156+
}
157+
158+
}
160159
</textarea></form>
161160
<script>
162161
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});

mode/nginx/nginx.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ CodeMirror.defineMode("nginx", function(config) {
127127

128128
token: function(stream, state) {
129129
if (stream.eatSpace()) return null;
130+
type = null;
130131
var style = state.tokenize(stream, state);
131132

132133
var context = state.stack[state.stack.length-1];
@@ -159,4 +160,4 @@ CodeMirror.defineMode("nginx", function(config) {
159160
};
160161
});
161162

162-
CodeMirror.defineMIME("text/nginx", "nginx");
163+
CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");

0 commit comments

Comments
 (0)