Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including the hostname in a HTML file served by nginx

Tags:

nginx

Does nginx offer a way to add the hostname (and port) in an HTML file (without using other solutions, such as PHP)?

like image 389
Flavio Copes Avatar asked Aug 14 '12 13:08

Flavio Copes


1 Answers

May be SSI is what you are looking for?

All variables, which available in core module also available in ssi module.

Usage example:

<!--# echo var="host" default="unknown_host" -->:<!--# echo var="server_port" default="unknown_port" -->

I had put this string inside test.html and invoke this page through http://localhost/test.html

As a result I get following string:

localhost:80
like image 116
CyberDem0n Avatar answered Nov 13 '22 18:11

CyberDem0n