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