: Nginx Php-Fpm Global Configuration So, ive got everything set with 6 wp websites sitting on my lemp stack. I have noticed that every single one of their nginx configurations are the same. Is
So, ive got everything set with 6 wp websites sitting on my lemp stack.
I have noticed that every single one of their nginx configurations are the same.
Is there a way I can globalize said configuration in nginx.conf?
For instance, caching sections, fastcgi, rewrites, etc...
More posts by @Courtney195
1 Comments
Sorted by latest first Latest Oldest Best
Yes, this is easy enough and a real time saver as the number of sites you manage increases.
In the /etc/nginx/conf.d/ directory, create one or more '.conf' files with the reusable config snippets you need. For example, type sudo nano /etc/nginx/conf.d/headers.conf and put your headers in the file. The default nginx.conf has a wildcard include directive at the bottom which will automatically pick these up.
If you have snippets that should only be used on some sites, delete the wildcard include directive from nginx.conf and selectively place new ones in your server blocks, one snippet per directive.
Here are some examples:
server {
listen 80;
server_name example.com;
include /etc/nginx/conf.d/headers.conf;
include /etc/nginx/conf.d/caching.conf;
...
}
server {
listen 443;
server_name example.com;
include /etc/nginx/conf.d/headers.conf;
include /etc/nginx/conf.d/caching.conf;
include /etc/nginx/conf.d/https.conf;
...
}
Don't forget to test your new rules sudo nginx -t and then reload your config sudo service nginx reload to apply the changes.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.