我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Nginx配置二级虚拟目录访问Laravel后台重写

案例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;

成都创新互联公司拥有一支富有激情的企业网站制作团队,在互联网网站建设行业深耕十余年,专业且经验丰富。十余年网站优化营销经验,我们已为上1000家中小企业提供了网站设计、成都网站建设解决方案,按需网站建设,设计满意,售后服务无忧。所有客户皆提供一年免费网站维护!

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;

}
}

网页标题:Nginx配置二级虚拟目录访问Laravel后台重写
网站地址:http://mswzjz.cn/article/ijepej.html

其他资讯