Skip to content

Commit 38f60f3

Browse files
authored
Change nginx layout of --open (#667)
When you run a build with `--open` we start a web server locally and open up a browser window for you to look at them. With the docker-based `build_docs` that server is nginx. nginx is fancy, and one of the things that we can do pretty easily is lay out the files that we serve so they look fairly like the public web site. This change does just that and it should come in handy to test future work we plan to do that generates an nginx config to deploy to the site serving the docs.
1 parent f3a7457 commit 38f60f3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

build_docs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def run_build_docs(args):
234234
# is weird. If we tell it that the browser's name is `open`
235235
# we'll get whatever the user set as their default browser.
236236
environ['BROWSER'] = 'open'
237-
webbrowser.open('http://localhost:8000', new=1, autoraise=False)
237+
webbrowser.open('http://localhost:8000/guide',
238+
new=1, autoraise=False)
238239
if should_forward_ssh_auth_into_container:
239240
match = re.match('Waiting for ssh auth to be forwarded to (.+)',
240241
line)

build_docs.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ sub build_local {
125125

126126
if ( $Opts->{open} ) {
127127
say "Opening: " . $html;
128-
serve_and_open_browser( $dir, 'index.html' );
128+
serve_and_open_browser( $dir );
129129
}
130130
else {
131131
say "See: $html";
@@ -245,7 +245,7 @@ sub build_all {
245245
check_links($build_dir);
246246
}
247247
push_changes($build_dir, $target_repo, $target_repo_checkout) if $Opts->{push};
248-
serve_and_open_browser( $build_dir, '/' ) if $Opts->{open};
248+
serve_and_open_browser( $build_dir ) if $Opts->{open};
249249

250250
$temp_dir->rmtree;
251251
}
@@ -710,7 +710,7 @@ sub serve_and_open_browser {
710710
if ( not $running_in_standard_docker ) {
711711
sleep 1;
712712
say "Press Ctrl-C to exit the web server";
713-
open_browser("http://localhost:8000/$open_path");
713+
open_browser("http://localhost:8000/");
714714
}
715715

716716
wait;
@@ -738,8 +738,8 @@ sub serve_and_open_browser {
738738
access_log /dev/stdout short;
739739
server {
740740
listen 8000;
741-
location / {
742-
root $dir;
741+
location /guide {
742+
alias $dir;
743743
add_header 'Access-Control-Allow-Origin' '*';
744744
if (\$request_method = 'OPTIONS') {
745745
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

0 commit comments

Comments
 (0)