Nginx.conf server blocks to separate .conf based on server_name

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I was just looking at the question here:
extract servers' blocks from Nginx conf
but it missed the closing '}' for the server block and i want to extract all the server blocks in the nginx.conf file to separate .conf files based on the first server_name of each block. the file might look like so:



 server { # php/fastcgi
listen 80;
server_name domain1.com www.domain1.com;
access_log logs/domain1.access.log main;
root html;

location ~ .php$
fastcgi_pass 127.0.0.1:1025;

server css' for the server block and i want to extract all the server blocks in the nginx.conf file to separate .conf files based on the first server_name of each block. the file might look like so:

 server { # php/fastcgi
listen 80;
server_name domain1.com www.domain1.com;
access_log logs/domain1.access.log main;
root html;

location ~ .php$
fastcgi_pass 127.0.0.1:1025;

server static)/
root /var/www/virtual/big.server.com/htdocs;
expires 30d;


# pass requests for dynamic content to rails/turbogears/zope, et al
location /
proxy_pass http://127.0.0.1:8080;



What i need is after running the code i get 2 .conf files for each server block.
Server running Centos 6,7 and don't have any restrictions regarding code or tools.
Thank you.







share' for the server block and i want to extract all the server blocks in the nginx.conf file to separate .conf files based on the first server_name of each block. the file might look like so:

 server { # php/fastcgi
listen 80;
server_name domain1.com www.domain1.com;
access_log logs/domain1.access.log main;
root html;

location ~ .php$
fastcgi_pass 127.0.0.1:1025;

server static)/
root /var/www/virtual/big.server.com/htdocs;
expires 30d;


# pass requests for dynamic content to rails/turbogears/zope, et al
location /
proxy_pass http://127.0.0.1:8080;



What i need is after running the code i get 2 .conf files for each server block.
Server running Centos 6,7 and don't have any restrictions regarding code or tools.
Thank you.







share' for the server block and i want to extract all the server blocks in the nginx.conf file to separate .conf files based on the first server_name of each block. the file might look like so:

 server { # php/fastcgi
listen 80;
server_name domain1.com www.domain1.com;
access_log logs/domain1.access.log main;
root html;

location ~ .php$
fastcgi_pass 127.0.0.1:1025;

server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log logs/domain2.access.log main;

# serve static files
location ~ ^/(images|javascript|js|css|flash|media|static)/
root /var/www/virtual/big.server.com/htdocs;
expires 30d;


# pass requests for dynamic content to rails/turbogears/zope, et al
location /
proxy_pass http://127.0.0.1:8080;



What i need is after running the code i get 2 .conf files for each server block.
Server running Centos 6,7 and don't have any restrictions regarding code or tools.
Thank you.









share|improve this question










share|improve this question




share|improve this question









asked Jun 6 at 12:00









Diablo2050

11




11











  • Found a good answer at stackoverflow.com/questions/9634953/…
    – Diablo2050
    Jun 6 at 12:16
















  • Found a good answer at stackoverflow.com/questions/9634953/…
    – Diablo2050
    Jun 6 at 12:16















Found a good answer at stackoverflow.com/questions/9634953/…
– Diablo2050
Jun 6 at 12:16




Found a good answer at stackoverflow.com/questions/9634953/…
– Diablo2050
Jun 6 at 12:16















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448183%2fnginx-conf-server-blocks-to-separate-conf-based-on-server-name%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448183%2fnginx-conf-server-blocks-to-separate-conf-based-on-server-name%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?