Nginx 配置二级虚拟目录访问 Laravel 后台重写
admin
2023-03-01 14:22:44
0

案例1
server {
listen 80;
listen 443 ssl http2;
server_name new.api.zentrust.cn;
root /var/www/new.api.zentrust.cn/prod/public;
index index.php index.html index.htm;
etag on;

gzip on;
gzip_vary on;
gzip_http_version 1.0;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_disable msie6;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/xml+rss;

client_max_body_size 110m;
client_body_buffer_size 1024k;

keepalive_timeout   60;

sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;

ssl_session_cache   shared:SSL:10m;
ssl_session_timeout 30m;
ssl_certificate /etc/nginx/ssl/new.api.zentrust.cn/fullchain.cer;
ssl_certificate_key /etc/nginx/ssl/new.api.zentrust.cn/privkey.key;

location ^~ /test {
    alias   /var/www/new.api.zentrust.cn/test/public;

    if (!-e $request_filename) {
            rewrite ^ /test/index.php last;
    }

    location ~ \.php$ {
            if (!-f $request_filename) {
                    return 404;
            }

            fastcgi_pass        unix:/tmp/php-fpm-72.sock;
            fastcgi_index       index.php;
            fastcgi_param       SCRIPT_FILENAME $request_filename;
            include             fastcgi_params;
    }
}

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    fastcgi_pass        unix:/tmp/php-fpm-72.sock;
    fastcgi_index       index.php;
    fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include             fastcgi_params;
}

location = /robots.txt  { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }

}

案例2
server
{
listen 80;
server_name test.myfxdd.com;
index index.html index.htm index.php default.html;
root /var/www/DD/test/myfxdd/view;

   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
    }
location / {
try_files $uri $uri/ /index.html;
}   
    location ~ .*\.(js|css)?$
    {
        expires      12h;
    }
    location @router {
        rewrite ^.*$ /index.html last;
    }

location /backend {
alias /var/www/DD/test/myfxdd/view/backend/public;
index index.html index.php;
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename) {
            rewrite ^ /backend/index.php last;
    }

location ~ \.php$ {
           if (!-f $request_filename) {
                    return 404;
            }

            fastcgi_pass         127.0.0.1:9000;
            fastcgi_index       index.php;
    fastcgi_param       SCRIPT_FILENAME $request_filename;
            include             fastcgi_params;
    }

location ~ \.php {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,lang,access-token';
    if ($request_method = 'OPTIONS') {
        return 204;
    }

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info       ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED /var/www/DD/test/myfxdd/view/backend/public/$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME /var/www/DD/test/myfxdd/view/backend/public/$fastcgi_script_name;
    include                       fastcgi_params;
}

    error_log  /usr/local/nginx/logs/error.dev.myfxdd.com.log;
access_log /usr/local/nginx/logs/access.dev.myfxdd.com.log;

}
}

相关内容

热门资讯

学习机直播乱象调查:主播打北大... 极目新闻记者 刘闪 何佳仪打开短视频平台,各类学习机测评直播间随处可见。一些自诩自己是“老师”的主播...
即日起,郑州“错峰加油”有优惠... 进入5月,又到了郑州臭氧污染频发的季节,记者从郑州市生态环境局移动源污染监管处了解到,为减少臭氧污染...
汗水写热爱 篮球致青春 成人组1VS1比赛。河南日报全媒体记者 黄晖 摄“非常高兴能够参加这种全民赛事,也希望以后能够有更多...
荷兰六六民主党全国办公室遭爆炸... 荷兰警方7日说,荷兰执政党之一的六六民主党位于海牙的全国办公室当晚遭爆炸物袭击,造成建筑受损,无人受...
樱花树油烟机总是开不了怎么回事 电源问题。先检查电源是否未插上或是否电,若没有,将它重新插好,等待来电后测试,检查开不了机的问题是否...
燃气灶打火后一会就灭是什么原因 原因可能是电池没有电了,所以一开始能够打着火,但是燃烧了一会儿又熄灭了,这种情况下可以尝试更换一节新...
灶盘有气儿,就是高压不打火 这种情况是点火器出了问题,如果点火器无法产生火花,那炉灶盘自然也就不能产生火,通常来说,如果灶台的开...
迅达热水器水流小怎么办 当你发现迅达热水器水流小时,可能会感到烦恼。然而,这个问题通常是很容易解决的。以下是一些可能导致水流...
迅达燃气灶打不着火 1、打火时看一下会不会有火花出来,如果没有火花就是电池没有电导致的打不着火。2、也有可能是迅达燃气灶...