walkor / webman

Probably the fastest PHP web framework in the world.
https://webman.workerman.net/
MIT License
2.12k stars 212 forks source link

How to use subdomain in webman #147

Open haidarvm opened 3 years ago

haidarvm commented 3 years ago

I have category in news site for example

http://news.example.com
http://category.example.com

how to create news app and other category app ?

a6965921 commented 3 years ago

you can use nginx proxy

haidarvm commented 3 years ago

you can use nginx proxy

I know, i'm using nginx proxy but how to detected it as subdomain ?

miaotaizi commented 3 years ago

中间件不能用吗?

haidarvm commented 3 years ago

中间件不能用吗?

can you give me example ?

haidarvm commented 3 years ago

@walkor can you solve this?

Without running multiple webman ?

Just from nginx conf ?

owenzhang24 commented 1 year ago

@haidarvm https://my.oschina.net/owenzhang24/blog/5585429 you can look my example

owenzhang24 commented 1 year ago

@haidarvm

![](https://oscimg.oschina.net/oscnet/up-a60e71de19404bf4b3e05882146b47fedad.png)

## www.owenzhang.com
index

127.0.0.1:8024

D:\owenzhang\workerman-owen\config\server.php

'listen'           => env('SERVER_LISTEN', 'http://127.0.0.1:8024'),

![](https://oscimg.oschina.net/oscnet/up-94d16596bf16373349479324d914428fcd7.png)

upstream webman { server 127.0.0.1:8024; }

server { listen 80; listen 443 ssl; server_name www.owenzhang.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/workerman-owen/public;

location / {
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header Host $host;
   if (!-f $request_filename){
      rewrite ^/(.*)$ /index/$1 break;
      proxy_pass http://webman;
   }
}

}


## www.ygkj.com
ygkj

server { listen 80; listen 443 ssl; server_name www.ygkj.com ygkj.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/workerman-owen/public;

location / {
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header Host $host;

   if (!-f $request_filename){
        rewrite ^/(.*)$ /ygkj/$1 break;
        proxy_pass http://webman;
     }
}

}


## admin.owen.com
admin

server { listen 80; listen 443 ssl; server_name admin.owen.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/workerman-owen/public;

 location / {
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header Host $host;
   if (!-f $request_filename){
      rewrite ^/(.*)$ /admin/$1 break;
      proxy_pass http://webman;
   }
}

}


## www.xmkzjhb.com
xmkzjhb

server { listen 80; listen 443 ssl; server_name www.xmkzjhb.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/workerman-owen/public;

location / {
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header Host $host;

   if (!-f $request_filename){
        rewrite ^/(.*)$ /xmkzjhb/$1 break;
        proxy_pass http://webman;
     }
}

}