'Including the hostname in a HTML file served by nginx

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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1