写给前端的Docker实战教程(16)

登录VPS服务器,安装 Nginx。因为我是 Ubuntu,所以可以用apt安装。其他 Linux 发行版可以百度下安装方法,通常2行内可以搞定:

apt update # 更新软件包

apt-get install nginx # 安装 Nginx

systemctl status nginx # 查看 Nginx 状态

此时本地通过浏览器访问 VPS 的公网 IP 可用看到 Nginx 的欢迎页面

然后在 VPS 服务器的/etc/nginx/conf.d/中建立一个vhost.conf文件,配置如下内容:

server {

listen 80;

server_name pea3nut.info;

location / {

proxy_pass http://127.0.0.1:8082;

}

}

配置的意思是,监听来自 80 端口的流量,若访问域名是pea3nut.info(替换为你自己的域名),则全部转发到http://127.0.0.1:8082中

推荐阅读