Want to dynamically configure virtual hosts on Nginx

Asked 4 months ago, Updated 4 months ago, 9 views

Q1.What does the link to "Additional 1: Virtual Document Routes for Apache with Nginx" do?
·It looks like it is dynamically processed using subdomains as variables, but I don't understand the contents

Would it be possible to dynamically do the following with the virtual host configuration in Q2.Nginx?
·Decided hit

http:// subdomain.domain
·Document root "/var/www/Domain/Subdomain.Domain"


·Document root "/var/www/example.net/a.example.net"

·Document root "/var/www/example.net/b.example.net"

·Document root "/var/www/example.com/a.example.com"

·Document root "/var/www/example.com/b.example.com"

Question Background
· "I think it would be good to add one by one to ""/etc/nginx/conf.d/*.conf"", but I want to write it as efficiently as possible




2022-09-30 11:17

2 Answers

A1: Obtain the subdomain name $subdomain of the requested host example.com, redirect to example.com if there is no content directory for the subdomain (/var/www/vhosts/$subdomain), or use the content directory for the subdomain.

A2: The site you are referring to does not provide a specific example of itself, but you can dynamically change the content directory per host by providing a folder.

2022-09-30 11:17


2022-09-30 11:17

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.