Use openresty to dynamically set host and openresty Dynamic host

Source: Internet
Author: User

Use openresty to dynamically set host and openresty Dynamic host
Use openresty to dynamically set host

Due to project requirements, nginx proxy needs to dynamically set the http_host parameter, which is not supported by native nginx. After investigation, it is found that openresty can implement:

1. Install openresty2. start nginx3. modify nginx configuration nginx. conf
Set_by_lua $ new_host 'local prefix = ngx. re. sub (ngx. var. http_host, "(xx-x-xxxxx -). * "," $1 "," o ") if prefix =" xx-x-xxxxx-"then local host = ngx. re. sub (ngx. var. http_host ,"(. *) :( [0-9] {2, 4}) "," $ 1.xx.com: $2 "," o ") return host; else return ngx. var. http_host; end 'proxy_set_header Host $ new_host; proxy_pass $ scheme: // $ new_host $ request_uri;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.