【问题标题】:Browser-Sync Proxy Middleware浏览器同步代理中间件
【发布时间】:2016-04-06 09:45:42
【问题描述】:

我有一个关于代理中间件的问题

我像这样初始化浏览器同步:

gulp.task('browser-sync', function() {
    files = [
        '**/*.php'
    ];
    browserSync.init(files,{
        open:false,
        port: 3000,
        ui: {
            port: 3000 + 1
        },
        proxy: {
            baseDir: "./",
            target : "http://example.com",
        }
    });
});

我使用 nginx 代理到http://127.0.0.1:3000

server {
    listen EXTERNAL_IP:80;
    server_name development.example.com;
    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}

但是浏览器同步调用 127.0.0.1:3000 而不是 http://development.example.com 如何告诉 browser-sync 它应该调用 http://development.example.com ? 谢谢!

【问题讨论】:

    标签: nginx proxy gulp middleware browser-sync


    【解决方案1】:
    server {
        listen EXTERNAL_IP:80;
        server_name development.example.com;
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://127.0.0.1:3000;
        }
    }
    

    这实际上是一个 nginx 的东西 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-15
      • 2017-06-04
      • 1970-01-01
      • 2016-05-11
      • 2022-08-10
      • 2017-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多