install Nginx iptables

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了install Nginx iptables相关的知识,希望对你有一定的参考价值。

  1. install the dependent package

    yum install -y pcre pcre-devel

    yum install -y zlib zlib-devel

  2. get nginx package

    wget http://nginx.org/download/nginx.1.8.1.tar.gz

  3. create user id for nginx

    useradd -M -s /sbin/nologin nginx

  4. install nginx

    tar xvzf nginx.1.8.1.tar.gz

    cd nginx.1.8.1

    ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_module

    make

    make install

    ln -s /usr/local/nginx/sbin/* /usr/local/sbin

  5. test nginx‘s configure file

    将nginx.conf的user nobody 改为user nginx

    nginx -t

  6. start nginx server

    nginx

  7. configure firewall

    iptables -F

    iptables -p INPUT DROP

    iptables -p FORWARD DROP

    iptables -p OUTPUT ACCEPT

    iptables -A INPUT -p tcp --dport 80 -j ACCEPT

     iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT (注:这个规则,如果你把OUTPUT 设置成DROP的就要写上这一部,好多人都是在这里被坑了。)

    若要永久生效,将changes写入/etc/sysconfig/iptables文件:

    /etc/rc.d/init.d/iptables save

    /etc/rc.d/init.d/iptables restart

  8. access to nginx from web client

以上是关于install Nginx iptables的主要内容,如果未能解决你的问题,请参考以下文章

The service already exists! The current server installed: D:mysqlmysql-5.7.30-winx64inmysqld My(代码片

nginx: [error] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)(代码片

iptables 详细使用

(转)mac 搭建基于RTMP的本地Nginx服务器报错homebrew/nginx was deprecated. This tap is now empty as all its form(代码片

Nginx禁止ip访问或IP网段访问方法

iptables导致nginx反向代理不可用的解决方案