Home  >  Q&A  >  body text

How to use nginx to achieve such a requirement?

For example, for user test, the domain name of test is test.com

Effect:
The user uploads static files to ~/test.com, which is the user’s home directory and the directory with the same name as the domain name
The user changes the test.com A record to point to our server and can access

 
 server {
        listen       80;
        server_name  ~^(www\.)?(.+)$;
        root  /home/lds/tmp/;
 }

This configuration can only be done if the directories with the same domain name are all under /home/lds/tmp.
Can all user home directories be set into one directory?

Actually what I want to do is

test1 user web directory is in ~/test1.com
The test2 user web directory is in ~/test2.com

in addition
Can all user home directories be set into one directory?

给我你的怀抱给我你的怀抱2712 days ago394

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 17:31:21

    I don’t know if I understand it correctly

    server {
            listen       80;
            server_name  ~^(www\.)?(.+)$;
            root  /home/lds/;
     }

    Isn’t this achieved

    test1 user web directory is at ~/test1.com
    test2 user web directory is at ~/test2.com

    In addition, you can put all users' homes in the same directory, but please configure the correct permissions.

    reply
    0
  • Cancelreply