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;

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;

}
}

原文地址:https://blog.51cto.com/13293070/2446557

时间: 2024-08-01 09:01:53

Nginx 配置二级虚拟目录访问 Laravel 后台重写的相关文章

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

server { listen 80; server_name _; root /opt/sites; 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

nginx 配置web 虚拟目录 并且codeIgniter,thinkphp 重新url 地址

nginx 配置虚拟目录并且url 重写 server { #侦听80端口 listen 8090; #定义使用www.xx.com访问 server_name 127.0.0.1; #设定本虚拟主机的访问日志 access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /home/lxy/www/cs/; #定义服务器的默认网站根目录位置 #默认请求 location / { index inde

LAMP虚拟主机配置以及控制目录访问

3.基于域名的虚拟主机配置 NameVirtualHost192.168.3.32:80#apache2.2.xx版本需要开启此选项,而且要和下面的保持一致:2.4.x版本就不需要此项设置了 <Virtualhost192.168.3.32:80> ServerName www.80.com DocumentRoot /var/www/html/80 </Virtualhost> <Virtualhost192.168.3.32:80> ServerName www.8

Windows下Nginx配置SSL实现Https访问(包含证书生成)

Vincent.李 Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https? HTTP全名超文本传输协议,客户端据此获取服务器上的超文本内容.超文本内容则以HTML为主,客户端拿到HTML内容后可根据规范进行解析呈现.因此,HTTP主要负责的是"内容的请求和获取".问题就出在这部分.行监控.劫持.阻挡等行为很容易导致网站泄密,一些关键参数比如登录密码开发者会在客户端

nginx配置网站所有目录下文件http认证

要实现网站所有目录均通过验证才能访问,可将nginx配置文件加为如下内容: location ^~ / { auth_basic "Authorized users only"; auth_basic_user_file wttxAuth.conf; } 这样访问网站及网站下所有文件均出现提示验证了. 注意,加上认证之后该目录下的PHP将不会被解析,会出现下载提示,如果想可以解析PHP可以将上面的配置改为: location ^~ / { location ~ .*.(php|php5

Nginx反向代理的目录访问问题

Nginx反向代理的目录访问问题 2013-05-13 23:21 2730人阅读 评论(0) 收藏 举报 从昨天就开始纠结了,在做实验的时候,遇到目录访问的问题,如下 前端nginx vhost的设置如下,代理访问后端的192.168.0.37 server { listen 80; server_name www.proxy.com; index index.php index.html index.htm; location /test/ { proxy_next_upstream htt

ProFTPD配置匿名登录与目录访问权限控制

对ProFTPD服务器配置匿名登录. 查看配置文件proftpd.conf.默认情况下配置文件中的,匿名登录配置User和Group均为ftp.查看/etc/passwd确认用户ftp,是否存在.命令行输入id ftp,查看用户ftp的所在组.查看/etc/group,确定用户组ftp是否存在. 上述步骤中,如果缺少用户或组,新建即可. User    ftp Group ftp UserAlias   anonymous ftp   #设置匿名用户以ftp身份登录 --------------

解决nginx发布网站跨目录访问

解决nginx发布网站跨目录访问(thinkphp5+lnmp) 到:usr/local/nginx/conf/vim fastcgi.cof 把最后一行加上井号#注释掉保存重启 restart 参考:http://www.cnblogs.com/q1104460935/p/7028881.html

JSP配置了虚拟目录使用JavaBean报错

今天遇到一个很棘手的问题,在jsp文件中使用useBean,网页返回码出现了500服务器内部错误,报错信息如下: The value for the useBean class attribute wp.A is invalid. 之前项目放在tomcat的webapps文件夹下,运行是正常的,现在是配置了虚拟目录,所以与javabean无关,应该是和配置了虚拟目录有关 尝试了很多方法都没用,最后找到了正确的解决方案(解决方法在最下面,如果会使用javabean的可直接跳过中间部分) 在此之前,