July 18, 2014 09:40AM
Hello nginx gurus,

First post but I have been reading this board for over a year!

My scenario:

I have many separate "sites" to run and they all use the same back end application(opencart). They also will be under the same domain, in folders. I don't want to duplicate the application code in each subdirectory.

I've got it working with a few sites and it works well. However, I will have ~200 sites soon.

Example sites:

domain.com/site1/
domain.com/site2/
etc...

My main code base is located at the root of domain.com.

I am currently using location rewrite blocks for each site.

That will get ugly when I have 200 sites, and a pain when I want to add new sites.

Can anyone help me with a "dynamic" configuration so I don't have to edit conf files each time?


===========================


server {
listen 80;
server_name domain.com;
root /etc/nginx/html/development;
error_log /var/log/nginx/dev.error.log;
index index.php;

rewrite ^([^.]*[^/])$ $1/ permanent; # trailing slash

# HERE IS THE CODE I WANT TO FIX
location ^~ /site1/ {
rewrite ^/site1/(.*) /$1;
}
location ^~ /site2/ {
rewrite ^/site2/(.*) /$1;
}
location ^~ /site3/ {
rewrite ^/site3/(.*) /$1;
}

}

=============================

Could I use map module, or possibly a single location regex?


Thanks!
Subject Author Posted

Multiple sites under same domain with one app codebase

martyparish July 18, 2014 09:40AM

Re: Multiple sites under same domain with one app codebase

martyparish July 18, 2014 09:53AM

Re: Multiple sites under same domain with one app codebase

Francis Daly July 18, 2014 10:52AM

Re: Multiple sites under same domain with one app codebase

martyparish July 18, 2014 11:17AM

Re: Multiple sites under same domain with one app codebase

itpp2012 July 18, 2014 11:50AM

Re: Multiple sites under same domain with one app codebase

martyparish July 18, 2014 12:08PM

Re: Multiple sites under same domain with one app codebase

martyparish July 18, 2014 12:23PM

Re: Multiple sites under same domain with one app codebase

itpp2012 July 18, 2014 01:12PM

Re: Multiple sites under same domain with one app codebase

martyparish July 18, 2014 01:21PM

Re: Multiple sites under same domain with one app codebase

itpp2012 July 18, 2014 02:21PM

[SOLVED] Re: Multiple sites under same domain with one app codebase

martyparish July 19, 2014 10:32AM

Re: [SOLVED] Re: Multiple sites under same domain with one app codebase

martyparish July 19, 2014 10:34AM

Re: [SOLVED] Re: Multiple sites under same domain with one app codebase

Edho Arief July 19, 2014 10:42AM

Re: [SOLVED] Re: Multiple sites under same domain with one app codebase

martyparish July 19, 2014 10:51AM

Re: [SOLVED] Re: Multiple sites under same domain with one app codebase

Edho Arief July 19, 2014 10:58AM

Re: [SOLVED] Re: Multiple sites under same domain with one app codebase

martyparish July 20, 2014 02:03PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready