Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Config for Enabling SSI nginx?

Tags:

nginx

ssi

I want to do server side include and i have nginx server installed in my machine and i cant find a way to enable ssi in nginx.conf file? all i can find from the internet is

syntax: ssi on | off;
default:    
ssi off;
context:    http, server, location, if in location
like image 544
inputError Avatar asked Oct 19 '25 15:10

inputError


2 Answers

Enable ssi on the location context. In my case i want it on root

location / {
   ssi on;
}
like image 185
inputError Avatar answered Oct 21 '25 10:10

inputError


It looks like you were having the same problem I was having; finding a crystal clear explanation of how to enable SSI on NGINX. Crystal Clear entails not just which syntax to use, but the format, and exactly where to include it. I figured it out and it's not that difficult, but the lack of clear instructions on the internet was frustrating.

You'll need to open up the nginx.conf file and look for the section that is formatted as follows (I've included the 'ssi on' syntax as well):

location / {
            root   E:\website\FinalJRLWeb;
            index  index.html index.shtml;
            ssi on;
        }

It took me a bit to realize the location, but it's really as simple as adding the line 'ssi on' right underneath the specified index file names (and it should be able to really go anywhere you'd like, I don't imagine the order matters, just as long as it's within the two brackets {}).

After that, to verify that SSI is working on your NGINX server, add the following line anywhere in the 'body' tag of a blank html page

<!--#echo var="DATE_LOCAL" -->

and save it with the extension .shtml in your web server's root directory.

You should see the server's local date and time displayed upon visiting your page. I realize this is almost a year old, but after my frustration trying to find clear instructions, I wanted to do my best to try and provide clear instructions for anyone else that may need them. So hopefully this will help someone out!

Here's NGINX's documentation page on SSI (which honestly was not helping me as much as I would have liked, but it nonetheless is useful, and can only become more and more useful)

http://nginx.org/en/docs/http/ngx_http_ssi_module.html#ssi_last_modified

like image 37
Soundfx4 Avatar answered Oct 21 '25 12:10

Soundfx4