Linux下的Nginx反向代理

需求

将准备好的域名使用Nginx反向代理,通过 域名 来访问服务器上的IP:8581

 

准备工作

系统环境 Ubuntu18.04

工具版本 Nginx/1.14.0 (Ubuntu)

服务器外网IP:114.215.183.37 (假设)

域名: kumatazz.net(假设)

 

Linux下配置

1. 服务器Linux系统下编写域名配置信息文件

cd /etc/nginx/sites-enabled
vim kumatazz.net

 如下内容:

server {
  server_name kumatazz.net;
  listen 80;
  location / {
    proxy_redirect off;
    proxy_pass http://127.0.0.1:8581;         // 不写IP地址访问速度更快
    proxy_http_version 1.1;
  }
}

 

 2. 查看nginx.conf文件

确认配置有没有将上一步的文件include进来:

vim /etc/nginx/nginx.conf

// 一般来说已经有include了,没有则加上去
include /etc/nginx/sites-enabled/*;

 

3. 重启nginx服务器

sudo  systemctl restart nginx

 

done !

posted @ 2020-01-15 18:14  kumata  阅读(1553)  评论(0编辑  收藏  举报