宝塔服务器(linux)服务器搭建

4 篇文章 0 订阅
2 篇文章 0 订阅

搭建服务器
nginx 搭配 PM2( 集合了node的功能 ) 搭建服务器

域名: http://kissface.top

流程如下:
服务器既做assets文件目录挂载 , 也当做nodejs服务使用

当我访问http://kissface.top 根目录时 展示index.html文件 同时能访问静态资源如 js/css/img/font 等

当我访问 http://kissface.top/nginx_connect 此路径时 访问nodejs服务

则前期环境 在这里插入图片描述
建站是不需要的 , 若建站后会让nginx 报错!!!

则nginx 关键配置如下


server
    {
        listen 80;
        server_name kissface.top www.kissface.top;
        index index.php index.html index.htm default.php default.htm default.html;
        root /www/wwwroot/kissface.top;

        location ~ /nginx_connect/(.*)$ {
          # 将 API 请求转发到 Node.js 应用程序
          proxy_pass  http://39.109.87.258:8081/$1?$args;
          proxy_redirect off;
          proxy_set_header Host $host;
        }
            
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }
        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}

核心配置

server_name kissface.top www.kissface.top;

index index.php index.html index.htm default.php default.htm default.html;

root /www/wwwroot/kissface.top;

location ~ /nginx_connect/(.*)$ {
# 将 API 请求转发到 Node.js 应用程序
proxy_pass http://39.109.87.258:8081/ 1 ? 1? 1?args;
proxy_redirect off;
proxy_set_header Host $host;
}

注意点 1. 服务器开放端口 2. 宝塔设置开放端口

自此 单独访问域名则展示页面 ; 访问域名后参数api 则请求接口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值