nginx vue php 第一个站点配置

Nginx服务器配置示例:整合API与支付处理
文章详细描述了如何在Nginx中配置两个服务器块,分别处理前端静态资源和API请求,以及支付接口的代理转发,同时提及与Apache的集成。

单独使用nginx

server {
        listen       8080;
        server_name  nlocal.ijisq.com;
        root /Users/xhcheng/ghworkspace/ijisq-front/dist;
        location / {
            try_files $uri $uri/ /index.html;
        }
        location /api {
            rewrite ^/api/(.*)$ /$1 break;
            proxy_pass http://127.0.0.1:8899;
        }
        location /pay {
            rewrite ^/pay/(.*)$ /paysdk/$1 break;
            #rewrite ^/pay/(.*)$ /paysdk/$1 permanent;
            proxy_pass http://127.0.0.1:8899;
        }
}
server {
        listen 8899;
        server_name 127.0.0.1;
        root /Users/xhcheng/bobworkspace/ijisq-api/public;
        location / {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
        location /paysdk/ {
            alias /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/paysdk/;
            index index.php;
        }
        location ~ ^/paysdk/.+\.php$ {
            root /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/;
            rewrite /paysdk/(.*\.php?) /$1 break;
            include fastcgi.conf;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/paysdk$fastcgi_script_name;
        }
        location ~ .+\.php($|/) {
            set $script $uri;
            set $path_info "/";
            if ($uri ~ "^(.+\.php)(/.+)") {
               set $script $1;
               set $path_info $2;
            }

            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php?IF_REWRITE=1;
            include fastcgi.conf;
        }
}

使用nginx+apache

server {
        listen       8080;
        server_name  nlocal.ijisq.com;
        root /Users/xhcheng/ghworkspace/ijisq-front/dist;
        location / {
            try_files $uri $uri/ /index.html;
        }
        location /api {
            rewrite ^/api/(.*)$ /$1 break;
            proxy_pass http://local.ijisq-api.com;
        }
        location /pay {
            rewrite ^/pay/(.*)$ /paysdk/$1 permanent;
            proxy_pass http://local.ijisq-api.com;
        }
}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值