nginx配置说明

nginx配置说明

server {
    listen    80;
    server_name example.com;
 
    location ^~ /project1 {
        proxy_pass     http://localhost:8081;
        proxy_set_header  Host       $host;
        proxy_set_header  X-Real-IP    $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
 
    location ^~ /project2 {
        proxy_pass     http://localhost:8082;
        proxy_set_header  Host       $host;
        proxy_set_header  X-Real-IP    $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
 
    location / {
       proxy_pass     http://localhost:8080;
       proxy_set_header  Host       $host;
       proxy_set_header  X-Real-IP    $remote_addr;
       proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
  1. listen:监听的端口是访问项目对应的端口,即外网可访问的端口
  2. proxy_pass:地址后的端口是你tomcat中配置的端口,即实际端口

参考连接:https://blog.csdn.net/cc_want/article/details/83780435

你可能感兴趣的:(tomcat,nginx,nginx,tomcat)