您现在的位置是:首页 >其他 >宝塔服务器(linux)服务器搭建网站首页其他
宝塔服务器(linux)服务器搭建
搭建服务器
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 则请求接口





U8W/U8W-Mini使用与常见问题解决
QT多线程的5种用法,通过使用线程解决UI主界面的耗时操作代码,防止界面卡死。...
stm32使用HAL库配置串口中断收发数据(保姆级教程)
分享几个国内免费的ChatGPT镜像网址(亲测有效)
Allegro16.6差分等长设置及走线总结