opencloud 8.6 配置nginx域名代理
1.配置服务器
1.确保服务器上安装了 Web 服务器:
sudo yum install nginx -y # 安装 Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
2.编辑虚拟主机配置文件:
vi /etc/nginx/nginx.conf
server {
listen 80 default_server;
#listen [::]:80 default_server;
server_name www.qwer.vip; #添加域名
#server_name _;
root /usr/share/nginx/html; #访问内容
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3. 测试 Nginx 配置:
sudo nginx -t
sudo systemctl restart nginx
4. 开放 80 端口
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports
5.配置hosts文件
sudo vim /etc/hosts
192.168.0.101 www.qwer.vip #添加
6.访问域名
curl -v www.qwer.vip
如果自己电脑需要访问的话,需要配置电脑自己的hosts
hosts位置:C:\Windows\System32\drivers\etc\hosts
host内容:192.168.0.101 www.qwer.vip #添加