代理

时间:2017-04-21 09:02:57

标签: nginx

需要路由

目前,http://backend打开后端,但我需要通过127.0.0.1/backend URL打开后端

以下nginx conf中缺少什么?

nginx - vhost.conf文件

server {
    listen 80 default;
    server_name frontend;

    root /app/frontend/web;
    index index.php index.html;

    location / {
       try_files $uri $uri/ /index.php?$args;
    }
}

server {
    listen 80;
    server_name backend;

    root /app/backend/web;
    index index.php index.html;


    location / {
       try_files $uri $uri/ /index.php?$args;
    }
}

托管文件如下 -

127.0.0.1 frontend
127.0.0.1 backend

1 个答案:

答案 0 :(得分:0)

server { 
  server_name backend;

location / {
# app1 reverse proxy follow
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:80;
  }
}

这应该有效! 也见:

http://wiki.nginx.org/HttpProxyModule#proxy_pass

https://www.nginx.com/resources/admin-guide/reverse-proxy/