user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
	worker_connections  1024;
}

http {
	client_max_body_size 100m;
	include       /etc/nginx/mime.types;
	default_type  application/octet-stream;

	log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
	                 '$status $body_bytes_sent "$http_referer" '
	                 '"$http_user_agent" "$http_x_forwarded_for"';

	access_log  /var/log/nginx/access.log  main;

	sendfile        on;
	#tcp_nopush     on;

	keepalive_timeout  65;

	server {
		listen       80;
		server_name  localhost;
		#后台服务配置，配置了这个location便可以通过http://域名/hrhx-boot/xxxx 访问
		location PROXY/BASE_API {
			proxy_pass              http://SERVER_IP:SERVER_PORT/BASE_API;#注意宿主机！！！！
			proxy_set_header        Host SERVER_IP;
			proxy_set_header        X-Real-IP $remote_addr;
			proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
		}
		#解决Router(mode: 'history')模式下，刷新路由地址不能找到页面的问题
		location /PUBLIC_PATH {
			alias  /usr/share/nginx/html/OUTPUTDIR/;
			try_files $uri $uri/ @router;
			index  index.html index.htm;
		}
		location @router {
			rewrite ^.*$ /PUBLIC_PATH/index.html last;
		}
		#配置websocket
		location /wss/ {
			proxy_pass http://SERVER_IP:SERVER_PORT/BASE_API/; #通过配置端口指向部署websocket的项目
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
			proxy_set_header X-real-ip $remote_addr;
			proxy_set_header X-Forwarded-For $remote_addr;
		}
	}

	#gzip  on;

	include /etc/nginx/conf.d/*.conf;
}
