[英]Browser-sync - proxy a domain gets HTTP error 403 - you don't have authorization to view this page
I run a gulp task using NodeJS module browser-sync as below.我使用 NodeJS 模块 browser-sync 运行 gulp 任务,如下所示。
=== File gulpfile.js === === 文件 gulpfile.js ===
let browserSync = require('browser-sync').create(); gulp.task('browser-sync', function(){ browserSync.init( { open: true, injectChanges: true, proxy: 'https://generalgulp.devsunset', host: '192.168.1.76', serveStatic: ['.'], https: { key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key', cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt' } }); });
=== === === ===
My local project information is as below (I use latest up to current post date):我的本地项目信息如下(我使用最新到当前发布日期):
I run the browser-sync task.我运行浏览器同步任务。 The output looks good.
output 看起来不错。
==> ==>
Using gulpfile C:\WebProjects\GeneralGulp\gulpfile.js使用 gulpfile C:\WebProjects\GeneralGulp\gulpfile.js
[Browsersync] Starting 'browser-sync'... [Browsersync] 开始“浏览器同步”...
[Browsersync] Proxying: https://generalgulp.devsunset [Browsersync] 代理: https://generalgulp.devsunset
Access URLs:访问网址:
Local: https://localhost:3000本地:https://localhost:3000
External: https://192.168.1.76:3000外部: https://192.168.1.76:3000
UI: http://localhost:3001用户界面:http://localhost:3001
UI External: http://localhost:3001 UI 外部:http://localhost:3001
==> ==>
I can access the site from both local & external address.我可以从本地和外部地址访问该站点。
However, when I try to access the local resources using proxied domain ( https://generalgulp.devsunset ), it gets an HTTP 403:但是,当我尝试使用代理域( https://generalgulp.devsunset )访问本地资源时,它会得到 HTTP 403:
Access to <my_custom_domain> was denied.
对 <my_custom_domain> 的访问被拒绝。 You are not authorize to view this page
您无权查看此页面
I suppose when running my gulp "browser-sync" task, it will translate the custom domain to the https://localhost:3000 or https://192.168.1.76:3000我想在运行我的 gulp “浏览器同步”任务时,它会将自定义域转换为 https://localhost:3000 或https ://300D807BADE5Z://3。
I have followed exactly the documents of https://browsersync.io/docs .我完全按照https://browsersync.io/docs的文档。 I have also made an attempt with all solutions I could find.
我也尝试了所有我能找到的解决方案。 Those solutions led me to the gulp task that I wrote at the beginning.
这些解决方案将我引向了我在开始时编写的 gulp 任务。
I would appreciate if you can suggest me which things I should do further to troubleshoot why does my browser-sync cannot “proxy” my domain?如果您能建议我进一步解决为什么我的浏览器同步无法“代理”我的域,我将不胜感激? Is there any parameter missing in my Gulp task?
我的 Gulp 任务中是否缺少任何参数?
Thanks !谢谢 !
I have modified the "proxy" parameter as below and it works when i access the proxied domain with given port: (for my case is http(s)://generalgulp.devsunset:3000 )我已经修改了“代理”参数,如下所示,当我使用给定端口访问代理域时它可以工作:(对于我的情况是 http(s)://generalgulp.devsunset:3000 )
`gulp.task('browser-sync', function(){
browserSync.init( {
open: true,
injectChanges: true,
proxy: 'generalgulp.devsunset',
host: '192.168.1.76',
serveStatic: ['.'],
https: {
key: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.key',
cert: 'C:\\WebProjects\\GeneralGulp\\resources\\certificates\\server-generalgulp.crt'
}
});
}); }); `
`
This is a temporary acceptable solution regarding to the current question scope.这是关于当前问题 scope 的临时可接受的解决方案。
However, What i expect is the browser-sync will auto-forward traffic from custom domain ( http(s)://generalgulp.devsunset ) to: ( http://192.168.1.76:3000 ).但是,我期望浏览器同步会将流量从自定义域( http(s)://generalgulp.devsunset )自动转发到:( http://192.168.1.76:3000 )。
Does browser-sync allow users to do it?浏览器同步是否允许用户这样做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.