search

Home  >  Q&A  >  body text

Operation and maintenance - Can nginx configure paths outside of IP and port?

For example, my program is localhost:8080/demo/

Matched to: localhost:9000/microsevice/demo, one more microsevice service name

我想大声告诉你我想大声告诉你2866 days ago494

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:20:37

    Maybe I misunderstood what you meant.
    Display localhost:8080/demo/,实际访问的是localhost:9000/microsevice/demo in the user’s browser URL.

    server {
       listen 8080;
       location ^~ / {
            # 如果需要的话
            #proxy_set_header Host $host;
            #proxy_set_header X-Real-IP $remote_addr;
           proxy_pass http://localhost:9000/microsevice/;
       } 
    }

    Displayed in the user’s browser URLlocalhost:9000/microsevice/demo,实际访问的是localhost:8080/demo/.

    server {
       listen 9000;
       location ^~ /microsevice/ {
            # 如果需要的话
            #proxy_set_header Host $host;
            #proxy_set_header X-Real-IP $remote_addr;
           proxy_pass http://localhost:8080/;
           # 最后那个 / 是必须的。
       } 
    }

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 17:20:37

    Yes, use proxy_pass

    reply
    0
  • Cancelreply