Hi John,<br><br>I&#39;ve not done any module development myself, so I don&#39;t know the specific capabilities, but I don&#39;t see why this wouldn&#39;t be possible to accomplish.&nbsp; Perhaps a module that does exactly as you say and sets a variable using the contents of a file, or a module that could read the contents of a file containing one or more variable declarations.&nbsp; It would be good to be able to specify when the file should be reloaded.&nbsp; This could be set to a number of requests between reloads, amount of time between reloads, or reloads based on some condition of a request.<br>
<br>Although I&#39;ve not come across this need myself yet, I can see where it could be quite useful.<br><br>Nick<br><br><br><div class="gmail_quote">On Fri, Jan 9, 2009 at 12:17 PM, Resicow <span dir="ltr">&lt;<a href="mailto:resicow@gmail.com">resicow@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Nick,<br>
<br>
Thanks for your thoughts, I really appreciate it!<br>
<br>
I know nginx is all about speed, and reading a file each time can be a waste of resources (hence no htaccess). I&#39;m not skilled in module development, but do you think it would be possible either as a custom module, or using the embedded perl module to accomplish this?<br>

<br>
There are a few things that I want to do besides the maintenance page, and basically they require the ability of setting a variable to the contents of a text file, which allows nginx to make some decisions, instead of checking for the existence of lots of files. Lets say I have 10 things I want nginx to do... wouldn&#39;t checking for the existence of 10 different files have more overhead than just reading the contents of one?<br>

<br>
<a href="http://wiki.codemongers.com/NginxHttpAccessKeyModule" target="_blank">http://wiki.codemongers.com/NginxHttpAccessKeyModule</a><br>
<br>
For example the access key module. Right now the access key signature is defined in the config file, and supports variables. So instead of changing the config file to change the signature, I could set the signature to a variable, and have that variable read each time from a text file, that could change anytime I wanted (and be different for different directories), without having to edit the config file and reload from command line.<div class="Ih2E3d">
<br>
<br>
Thanks,<br>
<br>
John<br>
<br>
<br>
<br>
<br>
<br>
Nick Pearson wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
Hi John,<br>
<br>
That&#39;s an interesting problem. &nbsp;There&#39;s no way that I&#39;ve seen that would let you read the contents of a file from the nginx config. &nbsp;Maybe someone else can shed some light on this.<br>
<br>
In any case, I&#39;m not sure you&#39;d want the overhead of opening and reading a file on every request. &nbsp;However, you might be able to come up with a solution using symlinks and/or a simple cron script that will make the appropriate file available to nginx when necessary. &nbsp;A command like this might work...<br>

<br>
if [ -s maintenance_file.txt ]; then ln -s `cat maintenance_file.txt` maintenance.html; elif [ -f maintenance.html ]; then rm maintenance.html; fi<br>
<br>
I tested this out locally, and it works. &nbsp;If the maintenance_file.txt file has text in it, it assumes the text is a filename and creates a symlink to that filename (at a location where nginx would see the symlink and serve the linked file as a maintenance page). &nbsp;If the maintenance_file.txt is empty and the symlink exists, then the symlink is deleted. &nbsp;(This could be made much more robust, but it works as is if the maintenance_file.txt is either empty or contains a single line with no newline/return characters.)<br>

<br>
I realize this isn&#39;t exactly what you&#39;re going for, but it might accomplish your goal. &nbsp;And ultimately, this will be more performant than having nginx read the contents of a file on each request.<br>
<br>
Nick<br>
<br>
<br></div><div><div></div><div class="Wj3C7c">
On Fri, Jan 9, 2009 at 11:12 AM, Resicow &lt;<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a> &lt;mailto:<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a>&gt;&gt; wrote:<br>

<br>
 &nbsp; &nbsp;Hi Nick,<br>
<br>
 &nbsp; &nbsp;Thanks for your response... I understand the response below, but I<br>
 &nbsp; &nbsp;was hoping for a way of doing this by reading the contents of the<br>
 &nbsp; &nbsp;text file... So something like this...<br>
<br>
 &nbsp; &nbsp; &nbsp;if (-f $document_root/system/back_soon.txt) {<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set $file_to_load read /$document_root/system/back_soon.txt<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite &nbsp;^(.*)$ &nbsp;$file_to_load last;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br>
<br>
 &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp;So if the file exists read and set a variable based on the<br>
 &nbsp; &nbsp;contents of the file, and then rewrite to the variable path.<br>
<br>
 &nbsp; &nbsp;Thanks,<br>
<br>
 &nbsp; &nbsp;John<br>
<br>
<br>
<br>
<br>
<br>
 &nbsp; &nbsp;Nick Pearson wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;John,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;See Ezra&#39;s response in the thread here:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://thread.gmane.org/gmane.comp.web.nginx.english/8978/focus=8990" target="_blank">http://thread.gmane.org/gmane.comp.web.nginx.english/8978/focus=8990</a><br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;That explanation is just for a single downtime notice, but you<br>
 &nbsp; &nbsp; &nbsp; &nbsp;can use a variation of his solution to accomplish what you<br>
 &nbsp; &nbsp; &nbsp; &nbsp;want. &nbsp;For example:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;server {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (-f $document_root/system/back_soon.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rewrite &nbsp;^(.*)$ &nbsp;/system/back_soon.html last;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (-f $document_root/system/down_for_a_while.html) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rewrite &nbsp;^(.*)$ &nbsp;/system/down_for_a_while.html last;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;This will show the back_soon.html page if it exists. &nbsp;If it<br>
 &nbsp; &nbsp; &nbsp; &nbsp;doesn&#39;t exist and the down_for_a_while.html page does, then<br>
 &nbsp; &nbsp; &nbsp; &nbsp;that will be displayed. &nbsp;Otherwise, processing will continue<br>
 &nbsp; &nbsp; &nbsp; &nbsp;normally.<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;On Thu, Jan 8, 2009 at 2:05 PM, Resicow &lt;<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a><br></div></div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a>&gt; &lt;mailto:<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a><div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:resicow@gmail.com" target="_blank">resicow@gmail.com</a>&gt;&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hello Nginx Community, and Happy New Year...<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Is it possible to set the value of a variable based on the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contents of a text file?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; So if there is site downtime, I can place a file in a directory<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; that nginx will see and will know to serve a downtime<br>
 &nbsp; &nbsp; &nbsp; &nbsp;notice, but<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then can nginx read the contents of the file to determine which<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; downtime notice to serve?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thanks,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; John<br>
<br>
<br>
<br>
<br>
<br>
</div></blockquote>
<br>
<br>
</blockquote></div><br>