Skip to content

整合之前的功能,同时开启防火墙,只允许内网访问,此时已经不是一台简单的反向代理服务器了, 应该称为网关服务器。

nginx
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    # 负载均衡
    upstream httpds {
      server 192.168.44.103;
    }

    server {
        listen       80;
        server_name  www.rainx.top;

        location / {
            # 伪静态 URL
            rewrite ^/([0-9]+).html$ /index.html?page=$1 break;
            # 反向代理
            proxy_pass http://httpds;
        }

        # 动静分离
        location ~*/(js|css|img) {
            root html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}