问题:使用阿里云主机和域名后,默认只能解析到ip的80端口,如果配置二级域名指向同一个ip的话是不成立的
解决方案:使用nginx反向代理服务器进行反向代理
原理:利用 nginx upstream机制使得nginx可以成为一个反向代理服务器,没画图软件后期补上
配置文件如下
1 worker_processes 1; 2 error_log logs/error.log; 3 pid logs/nginx.pid; 4 worker_rlimit_nofile 65535; 5 events { 6 use epoll; 7 worker_connections 65535; 8 } 9 http { 10 include mime.types; 11 default_type application/octet-stream; 12 sendfile on; 13 keepalive_timeout 65; 14 client_max_body_size 50m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为保存到本地再传给用户 15 client_body_buffer_size 256k; 16 client_header_timeout 3m; 17 client_body_timeout 3m; 18 send_timeout 3m; 19 proxy_connect_timeout 300s; #nginx跟后端服务器连接超时时间(代理连接超时) 20 proxy_read_timeout 300s; #连接成功后,后端服务器响应时间(代理接收超时) 21 proxy_send_timeout 300s; 22 proxy_buffer_size 64k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 23 proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置 24 proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2) 25 proxy_temp_file_write_size 64k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传递请求,而不缓冲到磁盘 26 proxy_ignore_client_abort on; #不允许代理端主动关闭连接 27 upstream www.kite.live { 28 server localhost:8080; 29 } 30 upstream pan.kite.live { 31 server localhost:8081; 32 } 33 34 server { 35 listen 80; 36 server_name pan.kite.live; 37 location / { 38 proxy_set_header Host $host; 39 proxy_set_header X-Real-IP $remote_addr; 40 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 41 proxy_pass http://pan.kite.live; 42 } 43 } 44 server { 45 listen 80; 46 server_name www.kite.live; 47 location / { 48 proxy_set_header Host $host; 49 proxy_set_header X-Real-IP $remote_addr; 50 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 51 proxy_pass http://www.kite.live; 52 } 53 } 54 }
时间: 2024-10-06 00:41:03