nginx config help

Discussion in 'HOWTO-Related Questions' started by autogun, Mar 9, 2014.

  1. autogun

    autogun New Member

    Hello Community,

    I'd like to achieve something as follow using nginx -

    When browsing to http://myserver/10.30.100.1 for example,
    I want proxy_pass to be set to http://10.30.100.1;

    What is the proper way to catch this and paste this to proxy_pass?

    Thank you
    Your answers are much appreciated,
     
  2. autogun

    autogun New Member

    Well, im getting somewhere but still need help,

    Catching the argument this way -
    Code:
    http://server/?device=10.10.21.102
    In nginx config -
    Code:
    set $ip $arg_device;
    proxy_pass  http://$ip;
    Which actually works but breaks when there's an image/css/js, for example -
    Code:
    [09/Mar/2014:23:05:44 +0200] "GET /?device=10.10.21.102 HTTP/1.1" 200 689 "-" "Mozilla/4.0 ...
    [09/Mar/2014:22:58:30 +0200] "GET /welcome.png HTTP/1.1" 500 594 "http://server/?device=10.10.21.102" "Mozilla/4.0 ... 
    When I try to access http://server/?device=10.10.21.102/welcome.png - It works.

    What would be the easiest way to solve this so css,js,images will be called as:
    GET /?device=10.10.21.102/welcome.png
    and not just
    GET /welcome.png
     
    Last edited: Mar 9, 2014
  3. autogun

    autogun New Member

Share This Page