NGINX: Option to keep configuration files untouched after manual edition.
[tomato.git] / release / src / router / www / nginx.asp
blob35025519de7a50e83c264014e3f7741d42020694
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2008 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 NGINX Web Server Management Control
8 Ofer Chen (roadkill AT tomatoraf dot com)
9 Vicente Soriano (victek AT tomatoraf dot com)
10 Copyright (C) 2013 http://www.tomatoraf.com
12 For use with Tomato Firmware only.
13 No part of this file can be used or modified without permission.
14 -->
15 <html>
16 <head>
17 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
18 <meta name='robots' content='noindex,nofollow'>
19 <title>[<% ident(); %>] Web Server Menu</title>
20 <link rel='stylesheet' type='text/css' href='tomato.css'>
21 <link rel='stylesheet' type='text/css' href='color.css'>
22 <script type='text/javascript' src='tomato.js'></script>
24 <!-- / / / -->
26 <style type='text/css'>
27 .controls {
28 width: 90px;
29 margin-top: 5px;
30 margin-bottom: 10px;
32 </style>
34 <script type='text/javascript' src='debug.js'></script>
35 <script type='text/javascript'>
37 // <% nvram("nginx_enable,nginx_keepconf,nginx_port,nginx_fqdn,nginx_docroot,nginx_priority,nginx_custom"); %>
39 changed = 0;
40 nginxup = parseInt ('<% psup("nginx"); %>');
42 function toggle(service, isup)
44 if (changed) {
45 if (!confirm("Unsaved changes will be lost. Continue anyway?")) return;
47 E('_' + service + '_button').disabled = true;
48 form.submitHidden('/service.cgi', {
49 _redirect: 'nginx.asp',
50 _sleep: ((service == 'nginxfp') && (!isup)) ? '10' : '5',
51 _service: service + (isup ? '-stop' : '-start')
52 });
55 function verifyFields(focused, quiet)
57 var ok = 1;
58 var a, b, c;
59 var i;
60 var vis = {
61 _f_nginx_keepconf : 1,
62 _f_nginx_port : 1,
63 _f_nginx_fqdn : 1,
64 _f_nginx_docroot : 1,
65 _f_nginx_priority : 1,
66 _f_nginx_custom : 1,
69 if (!E('_f_nginx_enable').checked) {
70 for (i in vis) {
71 vis[i] = 2;
75 for (a in vis) {
76 b = E(a);
77 c = vis[a];
78 b.disabled = (c != 1);
79 PR(b).style.display = c ? '' : 'none';
82 if (!v_port('_f_nginx_port', quiet))
84 ok = 0;
85 W('port');
88 if ((!v_length('_f_nginx_docroot', quiet, 1, 255)) || (!v_length('_f_nginx_fqdn', quiet, 1, 255)) || (!v_length('_f_nginx_custom', quiet, 1, 4096)))
90 ok = 0;
91 W('others');
94 changed |= ok;
95 return ok;
98 function save()
100 var fom = E('_fom');
101 if (!verifyFields(null, false)) return;
103 var en = fom.f_nginx_enable.checked;
104 fom.nginx_enable.value = en ? 1 : 0;
106 if (en) {
107 fom.nginx_keepconf.value = fom.f_nginx_keepconf.checked ? 1 : 0;
108 fom.nginx_port.value = fom.f_nginx_port.value;
109 fom.nginx_fqdn.value = fom.f_nginx_fqdn.value;
110 fom.nginx_docroot.value = fom.f_nginx_docroot.value;
111 fom.nginx_priority.value = fom.f_nginx_priority.value;
112 fom.nginx_custom.value = fom.f_nginx_custom.value;
115 if (!en) {
116 fom._service.value = 'enginex-stop';
117 } else {
118 fom._service.value = 'enginex-restart';
121 form.submit(fom, 1);
123 </script>
124 </head>
125 <body>
126 <form id='_fom' method='post' action='tomato.cgi'>
127 <table id='container' cellspacing=0>
128 <tr><td colspan=2 id='header'>
129 <div class='title'>Tomato RAF</div>
130 <div class='version'>Version <% version(); %></div>
131 </td></tr>
132 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
133 <td id='content'>
134 <div id='ident'><% ident(); %></div>
136 <!-- / / / -->
137 <div class='section-title'>Status</div>
138 <div class='section' id='status-section'>
139 <script type='text/javascript'>
140 W('NGINX is currently '+(!nginxup ? 'stopped' : 'running')+' ');
141 W('<input type="button" value="' + (nginxup ? 'Stop' : 'Start') + ' Now" onclick="toggle(\'nginxfp\', nginxup)" id="_nginxfp_button">');
142 </script>
143 <br>
144 </div>
145 </div>
147 <div class='section-title'>WEB Server Settings</div>
148 <div class='section' id='config-section'>
149 <form id='_fom' method='post' action='tomato.cgi'>
150 <input type='hidden' name='_nextpage' value='nginx.asp'>
151 <input type='hidden' name='_service' value='enginex-restart'>
152 <input type='hidden' name='_nextwait' value='10'>
153 <input type='hidden' name='_reboot' value='0'>
155 <input type='hidden' name='nginx_enable'>
156 <input type='hidden' name='nginx_keepconf'>
157 <input type='hidden' name='nginx_port'>
158 <input type='hidden' name='nginx_fqdn'>
159 <input type='hidden' name='nginx_docroot'>
160 <input type='hidden' name='nginx_priority'>
161 <input type='hidden' name='nginx_custom'>
163 <script type='text/javascript'>
164 createFieldTable('', [
165 { title: 'Enable Server on Start', name: 'f_nginx_enable', type: 'checkbox', value: (nvram.nginx_enable != '0') },
166 { title: 'Keep Config Files', name: 'f_nginx_keepconf', type: 'checkbox', value: (nvram.nginx_keepconf != '0') },
167 { title: 'Web Server Port', name: 'f_nginx_port', type: 'text', maxlen: 5, size: 7, value: fixPort(nvram.nginx_port, 85), suffix: '<small> default: 85</small>' },
168 { title: 'Web Server Name', name: 'f_nginx_fqdn', type: 'text', maxlen: 255, size: 20, value: nvram.nginx_fqdn },
169 { title: 'Server Root Path', name: 'f_nginx_docroot', type: 'text', maxlen: 255, size: 40, value: nvram.nginx_docroot, suffix: '<span>&nbsp;/index.html / index.htm / index.php</span>' },
170 { title: 'Server Priority', name: 'f_nginx_priority', type: 'text', maxlen: 8, size:3, value: nvram.nginx_priority, suffix:'<small> Max. Perfor: -20, Min.Perfor: 19, default: 10</small>' },
171 { title: '<a href="http://wiki.nginx.org/Configuration" target="_new">NGINX</a><br>Custom configuration', name: 'f_nginx_custom', type: 'textarea', value: nvram.nginx_custom }
173 </script>
174 </form>
175 </div>
176 <br>
178 <ul>
179 <span style='color:blue'>
180 <b>User Manual.</b><br>
181 </span>
182 <li><b>Note: This Feature is in Beta test, please test and report any bug you may find.</b>
183 <br>
184 <br>
185 <li><b> Status Button:</b> Quick Start-Stop Service. Enable Web Server must be checked to modify settings.<br>
186 <li><b> Enable Server on Start:</b> To activate the Web Server tick and save this screen.<br>
187 <li><b> Keep Config Files:</b> Did you modifed manualy the configuration files? OK, Tick it and changes will be maintained.<br>
188 <li><b> Web Server Port:</b> The Port used by the Web Server to be accessed.<br>
189 <li><b> Web Server Name:</b> Name that will appear on top of your Internet Browser.<br>
190 <li><b> Document Root Path:</b> The path in your router where documents are stored.<br>
191 <li><b> Examples:<br></b>
192 /tmp/mnt/HDD/www/ as you can find in USB mount path.<br>
193 <li><b> NGINX Custom Configuration:</b> You can add other values to nginx.conf to suit your needs.<br>
194 </span>
195 <span style='color:blue'>
196 <li><b> Server Priority:</b> Sets the service priority over other processes running on the router.<br><br>
197 The operating system kernel has priority -5.<br>
198 Never select a lower value than the kernel uses. Do not use the service test page to adjust the<br>
199 server performance, it's performance is lower than the definitive media where files will be <br>
200 located, i.e; USB Stick, Hard Drive or SSD.<br>
201 </span>
202 </ul>
203 <br>
205 <!-- / / / -->
207 </td></tr>
208 <tr><td id='footer' colspan=2>
209 <span id='footer-msg'></span>
210 <input type='button' value='Save' id='save-button' onclick='save()'>
211 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
212 </td></tr>
213 </table>
214 </form>
215 <script type='text/javascript'>verifyFields(null, 1);</script>
216 </body>
217 </html>