Nginx泛域名举例

来自linux中国网wiki
Evan讨论 | 贡献2019年10月14日 (一) 13:52的版本 (导入1个版本)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索
#web 目录
#有无数的目录 这样就不用再一个一个配置nginx了 
[root@debian 91]# ls /www/new91/gamesite/
mrsj  test


##nginx conf
[root@debian 91]# cat new91.cn.ssl.conf 
server {
        listen 80;
        listen 443 ssl;
        server_name  ~^(?<subdomain>.+)\.91\.cn;
	root /www/new9187/gamesite/$subdomain;
	ssl_certificate    /mon/91.cn.ssl.crt;   
        ssl_certificate_key   mon/91.cn.key; 
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   
        ssl_ciphers HIGH:!aNULL:!MD5;  
        charset utf-8;
        #access_log off;
        access_log  /logs/nginx/access.log  main;
        index Index.php index.php index.htm index.html;
	if ($scheme = http) {
        return 301 https://$subdomain.91.cn$request_uri;
        }
######################## just 4 ci by evan ******************************************
           location / {
#        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$query_string;
#        if (!-e $request_filename ){
#            rewrite ^/index.php/(.*)$ /index.php?s=$1 last;
#            rewrite ^(.*)$ /index.php?s=$1 last;
#        }
}
######################## just 4 ci by evan ******************************************
	if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry)') {
                set $mobile_request '1';
        }
        if ($mobile_request = '1') {
                rewrite ^(.*)/([^/]+).html$   $1/$2_m.html;
        }


        location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|html|htm|mp3|wma|js|css)$ {
                expires      7d;
        }
        location ~ .*\.php?$ {
                include /data/apps/nginx/conf/fastcgi.conf;
                fastcgi_pass 127.0.0.1:7000;
                fastcgi_index index.php;
        }
}