Skip to main content
  1. Posts/

Custom Index Page for Go Present

·335 words·2 mins
golang present nginx reverse proxy
drt
Author
drt

Overview #

Go’s present tool really comes in handy when making some presentations. I’ve been using it heavily for the Japanese class I teach. It’s really a simplistic and easy to use piece of software.

My biggest problem is the index page. If I were doing talks on Go, I wouldn’t mind so much, but for my Japanese class it’s not really ideal. I wanted a way to host my slides without users getting confused by all the “Go Programming Language” or “Go Talks”. I could have created an index.html file and use a reverse proxy to route the present tool to /slides/* but then users might try and go to /slides and see the present tool’s index page.

I wanted a way to:

  • make my own index page
  • hide the default page
  • make sure users couldn’t accidentally access the original

This proved to be harder than I thought. I was using nginx on my server and ended up achieving the desired result though a lot of keyboard slamming and guessing (also StackOverflow).

Solution #

Here’s the nginx config file in sites-enabled

server {
  listen 80;
  listen [::]:80;

  server_name gopresent.example.org;

  root /opt/learn-japanese-slides;

  location = / {
    try_files /index.html =404;
  }

  location / {
    proxy_set_header  Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  X-Forwarded-Proto $scheme;

    proxy_pass   http://localhost:3999;
  }
}

It’s pretty helpful, I can keep my index.html in the root of my slide decks folder and commit it all at the same time.

Downsides to this Approach #

In the original page, the slides are loaded dynamically. That is no longer the case. Now, every time I create a new slide deck, I have to manually create a link to it. Which isn’t too terrible. I can work on a slide deck and check it online before linking to it. Which has its benefits.


References #