Last active
November 11, 2022 00:22
-
-
Save nginx-gists/210b6e57bde33ec23099bc92326d2fd0 to your computer and use it in GitHub Desktop.
Make Your NGINX Config Even More Modular and Reusable with njs 0.7.7
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
server { | |
listen 4001; | |
js_import util from util.mjs; | |
location /foo { | |
js_content util.handler; | |
} | |
} | |
# vim: syntax=nginx |
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
server { | |
listen 4001; | |
location /foo { | |
# Where is 'util' defined? It's not obvious in this context | |
js_content util.handler; | |
} | |
} | |
# vim: syntax=nginx |
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
http { | |
# util.mjs is not actually invoked in this file | |
js_import util from util.mjs; | |
# This reads in jscode_local.conf, where 'util' is actually invoked | |
include /etc/nginx/conf.d/*.conf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a discussion of these files, see Make Your NGINX Config Even More Modular and Reusable with njs 0.7.7