worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

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

		location / {
            root   /usr/share/nginx/html;
			try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
		
		location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://app-api:8080/;
		}
        #配置代理转发
		location /wechat/ {
			proxy_pass http://app-api:8080/wechat/;
		}
		location /por/ {
			proxy_pass http://10.0.4.14:9000/;
		}
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
}
stream {
    #配置redis端口转发, 对外端口9001转到内部6379端口
	upstream redis {
		server 10.0.4.14:6379 max_fails=3 fail_timeout=30s;
	}
	server {
		listen 9001;
		proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass redis;
	}
	
}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐