在debian系统下 配置nginx 如何实现访问443端口的app路径是重定向到12700112345访问443端口的chat路径时以varwwwhtmlchatgpt-htm为根路径以indexhtml为首页
- 安装nginx
在终端中输入以下命令安装nginx:
sudo apt-get update
sudo apt-get install nginx
- 配置nginx
在终端中输入以下命令打开nginx配置文件:
sudo nano /etc/nginx/sites-available/default
在文件中添加以下代码:
server {
listen 443;
location /app {
return 301 http://127.0.0.1:12345;
}
location /chat {
root /var/www/html/chatgpt-htm;
index index.html;
}
}
保存并退出文件。
- 重启nginx
在终端中输入以下命令重启nginx:
sudo systemctl restart nginx
现在访问https://yourdomain.com/app将重定向到http://127.0.0.1:12345,访问https://yourdomain.com/chat将以/var/www/html/chatgpt-htm/为根路径,以index.html为首页。
原文地址: http://www.cveoy.top/t/topic/beOf 著作权归作者所有。请勿转载和采集!