Home  >  Q&A  >  body text

Asking for advice on the problem of nginx address forwarding

When a request is made to access a file under /test/, it is forwarded to ip: port 80. How to configure this under nginx

The following is the configuration file content
upstream api_servers {
server 127.0.0.1:9500;

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

keepalive 16;
}
server {
listen 80;
server_name www.yuming.com;
root /home/yuming/web;

listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

location ~*\.(jpg|gif|png|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar|txt|amr|js|css|html?)$ {
root /home/yuming/web;
}

location / {
proxy_pass http://api_servers;
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_Forwardeded_For;
Client_max_body_size 10m;
Client_bule_size 128k;
Proxy_timeout 90;
PROXY_SEN d_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4K 4K 4K proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_http_version 1.1;
proxy_set_header Connection "";
}

}

ringa_leeringa_lee2713 days ago376

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 17:23:28

    location ^~/directory/{

        proxy_pass   http://ip:80;
    }

    reply
    0
  • Cancelreply