Last active
October 15, 2023 11:45
-
-
Save highgain86j/7b1d0a406cbe06e3b3c0f4492b9045ac to your computer and use it in GitHub Desktop.
nginx configuration for host-only to fqdn redirecting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Where you have local httpd and client machines receiving domain-name via DHCP, following addition to nginx config | |
;would often be useful. | |
;For clarification, client machines get domain-name specified as 'intra.example.com' via DHCP in this example. | |
;BTW this type of setup is often found in situations where hostname-only name resolution would make things easier, say where | |
;you have Windows Active Directory in place, or local resources available, like network printers, NAS and so on. | |
;Whils specifying local domain over DHCP serves well for simple name-resolution applications that does not require FQDN, | |
;virtual-hosts as typically found configured on web servers would not favor that. | |
;Specifically, requests to something like 'http://www' must be redirected to 'http://www.intra.example.com', the proper FQDN. | |
; | |
;As per nginx documentation, you may have multiple server_name directives each specifying different host-only part of fqdn. | |
server { | |
listen 80; | |
server_name www; | |
return 301 http://$host.intra.example.com$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment