nginx 反向代理和静态资源配置

  • 反向代理访问:http://localhost/VnqQv2
  • 静态资源访问:http://localhost/static/index.html
http {
    include       mime.types;
    default_type  application/octet-stream;
    
    # 反向代理到9015端口
    upstream tomcatServer1 {
        server localhost:9015;
    }

    server {
        listen       80;
        server_name  localhost;
        
        location / {
            proxy_pass http://tomcatServer1;
            proxy_set_header HOST $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}

        # 静态资源访问地址:实际访问/data/static/下的资源
	location /static/ {
            root   /data/;
        }
    }
}

 

你可能感兴趣的:(常用工具)