Commonly used Nginx settings for front-end development

Nginx is commonly used for front-end deployment. There are not many configurations commonly used for front-end development, and it needs to be mastered

Common configuration instructions, only the core code of the server module is listed here

server {
    
    
        listen 9015; # 端口号
        server_name 172.16.101.191; # 浏览器访问域名,不配置默认为本服务器地址
        index index.html; # 入口文件
        client_max_body_size 1024m;

        root /usr/share/html/h5; #请求资源的根目录 
        try_files $uri $uri/ /index.html; #依次检测$root/$uri $root/$uri/ 是否存在,不存在则重定向到/index.html
        # 后台接口配置 
        location /users {
    
    
            proxy_set_header Host $host; # 传递域名
            proxy_set_header X-Real-Ip $remote_addr; # 传递ip
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Scheme $scheme; # 传递协议  
            #http://example.com/users/profile,我们想把其中的 /users 替换为 /members 
            rewrite /users/(.*) /members/$1 break; # 这里的 $1 表示匹配的第一个括号中的内容 # break 表示停止匹配之后的规则             
            proxy_pass http://172.16.101.106:8080; # 反向代理服务的地址
        }

        # 登录
        location /login {
    
    
            proxy_set_header Host $host; # 传递域名
            proxy_set_header X-Real-Ip $remote_addr; # 传递ip
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Scheme $scheme; # 传递协议        
            proxy_pass http://172.16.101.191:9017;
        }        
    }

Cooperate with Jenkins to realize automatic construction

The configuration of Jenkins is not explained here, but briefly the principle of Jenkins
insert image description here

Guess you like

Origin blog.csdn.net/lqh4188/article/details/131581688