nginx+防火墙基本配置

nginx基本配置

# 启动用户
#user  nobody;
worker_processes  1;
# 错误日志打印
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;
    # 访问日志打印
	access_log  logs/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
	
	# 反向代理
	server {
		# 监听端口
        listen       81;
        # nginx server地址,如果绑定域名可以填写域名
        server_name  100.100.100.100;
		# 代理设置
        location / {
        	# 转发超时时间设置 单位:秒
        	proxy_read_timeout 10;
        	# 转发地址
            proxy_pass http://100.200.300.400:8090;
        }
	}
	server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        # 充当静态服务器
        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
	}
}

linux防火墙常用操作

# 开启防火墙
systemctl start firewalld
# 关闭防火墙
systemctl stop firewalld
# 查看端口开放情况
firewall-cmd --list-ports
# 开放某个特定的端口
firewall-cmd --zone=public --add-port=81/tcp --permanent
# 关闭某个特定的端口
firewall-cmd --remove-port=80/tcp --permanent
# 更改配置后重启防火墙
systemctl reload firewalld
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值