Does nginx offer a way to add the hostname (and port) in an HTML file (without using other solutions, such as PHP)?
1 Answer
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
4 Comments
Flavio Copes
I'd like to retrieve it automatically, maybe a nginx-provided variable I can drop in. I could resort to get it from a hardcoded HTML file if there's no other way, but I'm curious to see if there's some other option.
Flavio Copes
Well, something like the $date_local or $date_gmt variables offered by SSI, but with hostname and port
CyberDem0n
I've updated my answer, you can find example of usage SSI module
Erkan Şirin
Don't forget to add ssi on; to nginx.conf