程序员

nginx 代理 请求转发 前台

2019-12-27  本文已影响0人  会去大草原的程序猿

前台是个报表系统,angular写的。后台是springboot项目。还有中台。还有nginx等。

想做的是在windows环境下,把前台部署到nginx上。请求后台。

直接上nginx的配置吧。最关键的是配置转发和地址方面。(个人比较走歪路的)

主配置文件:


    worker_processes  auto;
    events {
        worker_connections  1024;
    }
    http {
        include                 mime.types;
        default_type            text/html;
        port_in_redirect        off;
        sendfile                on;
        server_tokens           off;
        client_max_body_size 200m;
        client_body_buffer_size 100m;

        
        include sboard.conf;

    }

附属配置

server {
        listen          80;
        server_name     localhost;
        charset         utf-8;
        

        location ~ .*\.(gif|jpg|png|css|js|flv|ico|swf)(.*) {
                #expires 30d;
                add_header Cache-Control no-store;
                add_header Pragma no-cache;
                root ./html/sboard;-------路径:上级路径用一个.
        }

        location /
        {
                root ./html/sboard;-------路径:上级路径用一个.
        }
        location =/ {
                return          301                    /index.html;
        }

        location /dashboard/     --------转发检测的是从ip:port之后的字符,替换的是url中一直到配置的字符串。
        {       
                proxy_pass         http://10.203.109.135:9081/dashboard/;
                proxy_set_header   Host                 $host;
                proxy_set_header   X-Real-IP            $remote_addr;
                proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
                proxy_set_header   Cookie               $http_cookie;
        }
}
上一篇 下一篇

猜你喜欢

热点阅读