nginx设置通过二级域名反向代理到指定端口下的服务

#定义一组服务器

server
{
	listen 80;
	server_name admin.test.com;
	location / {
	proxy_pass http://movie.laityvip.cn;
		proxy_redirect  off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		client_max_body_size 20m;
		client_body_buffer_size 256k;
		proxy_connect_timeout 90;
		proxy_send_timeout 90;
		proxy_read_timeout 90;
		proxy_buffer_size 8k;
		proxy_buffers 4 64k;
		proxy_busy_buffers_size 128k;
		proxy_temp_file_write_size 128k;
	}
}

upstream movie.laityvip.cn {
		ip_hash;
		server 127.0.0.1:81;
}
server
{
		listen 80;
		server_name api.test.com; 
		location / {
			proxy_redirect off;
			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://localhost:8080;
	 }
}

————— 原文链接:https://blog.csdn.net/daguanjia11/article/details/99288499

1评论
  • 16:46

    movie.laityvip.cn