Nginx代理静态页面访问后台

Nginx代理静态页面访问后台

    • 1.修改Nginx的配置文件

1.修改Nginx的配置文件

	 #后端访问地址
    upstream savewater{
    #ip_hash;
		server 127.0.0.1:9081 weight=1 max_fails=2 fail_timeout=30s;
    }
   
    #监听本机80端口,前端访问拦截,编译前的文件
    server {
	
        listen 80 default_server;
        root C:\Users\Administrator\Desktop\static;
        server_name www.wangbo.com;
		index login.html;

        location / {
            #root /gaofeng/static;
            #index index.html;

            proxy_set_header  Host  $host:$server_port;
            proxy_next_upstream http_502 http_504 error timeout invalid_header;
            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_pass http://savewater;
            expires      -1;
        }
		
		location ~ .*\.(php|jsp|cgi)?$
		{
			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_pass http://savewater;
			expires      -1;
		}

        #通配
		location = /{
	        root C:\Users\Administrator\Desktop\static;
			index login.html;
		}

		location ~ \.(htm|html|gif|jpg|jpeg|png|ico|rar|css|js|zip|txt|flv|swf|doc|ppt|xls|pdf|woff2|woff|ttf)$
		{
		   root C:\Users\Administrator\Desktop\static;
			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_pass http://webpack;
			expires      -1;
		}
   }

Nginx代理静态页面访问后台_第1张图片
Nginx代理静态页面访问后台_第2张图片

你可能感兴趣的:(个人纪录)