Proxied host port is stripped from HTTP_HOST
See original GitHub issueWhen I use version 2.7.6 PHP’s $_SERVER[‘HTTP_HOST’] returns localhost:3000 but on the latest version, 2.7.12, it returns just localhost, without the port number. This is breaking my sites.
Example config:
gulp.task('serve', ['stylesDev'], function () {
browserSync.init({
notify: false,
proxy: 'localhost/src/'
});
gulp.watch(['src/**/*.php'], reload);
gulp.watch(['src/styles/**/*.{scss,css}'], ['stylesDev', reload]);
gulp.watch(['src/scripts/**/*.js'], reload);
gulp.watch(['src/images/**/*'], reload);
});
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Port number is stripped from Host http header. #1347 - GitHub
When a http request hits kong with a http header Host: en.wikipedia.org:8080 then Kong correctly forwards this http header, but it strips ...
Read more >What causes HttpHostConnectException? - Stack Overflow
A "connection refused" error happens when you attempt to open a TCP connection to an IP address / port where there is nothing...
Read more >http redirect and port stripping - DevCentral
All,. Can anyone assist me with an iRule that would strip a certain string out of a url? The customer has a vip...
Read more >http-host - ADMX Help
Description: Host name to use for HTTP requests. Type: String. Default: ''. Supported on: Host name for HTTP requests. Registry Hive ...
Read more >Using Behind a Reverse Proxy — waitress 2.1.2 documentation
If you're using Waitress behind a reverse proxy, you'll almost always want your reverse proxy to pass along the Host header sent by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m referring to the value returned by the PHP $_SERVER variable when using browser-sync’s proxy: //in gulpfile.js browserSync.init({ proxy: ‘localhost/’ });
Here’s an example:
//Without browser-sync
<?php echo $_SERVER['HTTP_HOST'];?>//returns localhost
//With Browser-Sync v2.6.5
<?php echo $_SERVER['HTTP_HOST'];?>//returns localhost:3000
//With Browser-Sync v2.7.12
<?php echo $_SERVER['HTTP_HOST'];?>//returns localhost
The issue I have is that, with the latest browser-sync version, it loads the site to http://localhost:3000/ on startup but the links in the site, which are generated dynamically by using $_SERVER[‘HTTP_HOST’] are using http://localhost/. The difference, not appending the :3000, raises browser errors related to cross-origin requests for resources.
Possible related issue when I try to save a WP post:
Here’s the relevant gulpfile.js code:
However, this is only an issue on an older site. I created a brand new site and had no issues. When I create a WP site, I install it at 127.0.0.1/mydir/. I run Gulp and it loads as localhost:3000/mydir/ just fine. Not sure if that helps @KevinRay.