Nginx安装及配置反向代理

今天做了个简单的反向代理,确一直失败,后来看了相关文档后,捋清思路,记录下来,方便日后使用。

一. 安装nginx:

1. sudo apt-get update

2. sudo  apt-get install nginx

二. 配置反向代理:

1. vi /etc/nginx/nginx.conf

2. 

server {
  listen 80; #端口号
  server_name 阿里云ip; #域名,由于域名认证有三个月等待时间,所以使用阿里云的ip
  location / {
    proxy_pass http://127.0.0.1:8000/; # springboot启动后项目访问路径
    proxy_read_timeout 6000;
  }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root html;
  }
}

3. 如果报错,nginx -t 查看配置是否正确

4. systemctl restart nginx 重启nginx

原文地址:https://www.cnblogs.com/hooli/p/11886475.html