Ubuntu16.04 Nginx 安装和 配置反向代理(配合docker run)

https://mp.csdn.net/postedit/100945051
在这篇文章中 run 的 宿主机的 8080 端口

sudo apt-get update

sudo apt-get install nginx

查看Nginx 版本

sudo nginx -v

打开nginx 配置目录:

cd /etc/nginx/sites-available
sudo vi default

 

在 default 文件中写入以下内容 进行保存

server {

  listen 80;

  location / {

    proxy_pass http://localhost:8080;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection keep-alive;

    proxy_set_header Host $http_host;

    proxy_cache_bypass $http_upgrade;

  }
}


重新加载Nginx
sudo nginx -t
sudo nginx -s reload

访问 80 端口 效果如下:


访问 8080 端口 效果如下:

猜你喜欢

转载自blog.csdn.net/CsethCRM/article/details/100997143