Mas_Tan

Site blog for Tan

No Praise For Colorful


Welcome To My Blog

Nginx 配置反向代理

最近要搭个EOS节点,然后在AWS租用了个 Ubuntu服务器,运维大哥呢,只帮我开了三个端口 80,22,443

当我用启动eos服务节点时,修改了启动的端口为80,如下 http-server-address = 0.0.0.0:80

但是启动起来报错,排查也没发现 80 端口被占用。后来换 443 也不行。反正默认的 8888 端口时可以的。

两个办法:

  • 让运维给我开放 8888 端口。
  • 利用 nginx 做反向代理,将80 端口代理给本地的 8888 端口。

最终选择 第二个办法,不是因为它方便。

主要是为了防止全网扫描定位高防后的服务器,修改默认的 8888 端口 至全网最大存活数量的端口 80 ,这样可以有效抬高攻击者的定位成本。

Nginx

安装

这里利用最简单的安装方式

sudo apt-get install nginx

启动

sudo /etc/init.d/nginx start

在浏览器输入ip,看是否nginx已成功启动

修改配置

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

替换 localtion / {***} 中的内容如下

    location / {
        proxy_pass http://localhost:8888; 
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

测试

sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

如果有上述输出则表示OK.

重启Nginx服务

sudo /etc/init.d/nginx start

这样就不用指定端口,就访问到对应服务器的8888 了。

最近的文章

C++ 面试

layout: posttitle: C++ 面试date: 2018-07-14 15:59:28.000000000 +09:00—为什么C++的 member function template不能是virtual的 ? 一个类的成员函数不能既是 template 又是 virtual 的class Animal{ public: template<typename T> virtual void make_sound(){ //.....…

继续阅读
更早的文章

EOS 搭建网络

安装本地环境下载代码下载最新代码,master 分支即可,--recursive 会把submodule 也一起下载下来git clone https://github.com/EOSIO/eos --recursive编译安装切换到eos 目录,执行 eosio_build.sh 脚本cd eos./eosio_build.sh最后出现 EOSIO 几个超大的字母就是OK 了。验证安装是否成功Linux:~/opt/mongodb/bin/mongod -f ~/opt/mongodb/...…

继续阅读