Add a custom HTTP header to requests made to your Discourse

Add this to your app.yml:

## Remember, this is YAML syntax - you can only have one block with a name
run:
  - exec: echo "Beginning of custom commands"

  # A man's not dead while his name is still spoken.
  - replace:
     filename: "/etc/nginx/conf.d/discourse.conf"
     from: /location \/ {/
     to: |
       location / {
           add_header X-Clacks-Overhead "GNU Terry Pratchett";

Make sure to rebuild the container afterwards.

Terry Pratchett, author of the Discworld novels, went hand-in-hand with Death on the 12th of March, 2015.

The Hour of the Dead was when men died. And when a man died, they sent him home by clacks. Moist’s mouth dropped open. ‘Huh?’

‘That’s what they call it,’ said Harry. ‘Not lit’rally, o’ course. But they send his name from one end of the Trunk to the other, ending up at the tower nearest his home.’

‘Yeah, but they say sometimes the person stays on in the towers, somehow,’ said Jim.’ “Living in the Overhead”, they call it.’

A lot of what travelled on the Grand Trunk was called the Overhead. It was instructions to towers, reports, messages about messages, even chatter between operators, although this was strictly forbidden these days. It was all in code. It was very rare you got Plain in the Overhead. But now . . . ‘There it goes again,’ she said. ‘It must be wrong. It’s got no origin code and no address. It’s Overhead, but it’s in Plain.’ On the other side of the tower, sitting in a seat facing the opposite direction because he was operating the up-line, was Roger, who was seventeen and already working for his tower-master certificate. His hand didn’t stop moving as he said: ‘What did it say?’

‘There was GNU, and I know that’s a code, and then just a name. It was John Dearheart. Was it a—’

‘You sent it on?’ said Grandad. Grandad had been hunched in the corner, repairing a shutter box in this cramped shed halfway up the tower. Grandad was the tower-master and had been everywhere and knew everything. Everyone called him Grandad. He was twenty-six. He was always doing something in the tower when she was working the line, even though there was always a boy in the other chair. She didn’t work out why until later. ‘Yes, because it was a G code,’ said Princess. ‘Then you did right. Don’t worry about it.’

‘Yes, but I’ve sent that name before. Several times. Upline and downline. Just a name, no message or anything!’ She had a sense that something was wrong, but she went on: ‘I know a U at the end means it has to be turned round at the end of the line, and an N means Not Logged.’ This was showing off, but she’d spent hours reading the cypher book. ‘So it’s just a name, going up and down all the time! Where’s the sense in that?’ Something was really wrong. Roger was still working his line, but he was staring ahead with a thunderous expression. Then Grandad said: ‘Very clever, Princess. You’re dead right.’

‘Hah!’ said Roger. ‘I’m sorry if I did something wrong,’ said the girl meekly. ‘I just thought it was strange. Who’s John Dearheart?’

‘He . . . fell off a tower,’ said Grandad. ‘Hah!’ said Roger, working his shutters as if he suddenly hated them. ‘He’s dead?’ said Princess. ‘Well, some people say—’ Roger began. ‘Roger!’ snapped Grandad. It sounded like a warning. ‘I know about Sending Home,’ said Princess. ‘And I know the souls of dead linesmen stay on the Trunk.’

‘Who told you that?’ said Grandad. Princess was bright enough to know that someone would get into trouble if she was too specific. ‘Oh, I just heard it,’ she said airily. ‘Somewhere.’

‘Someone was trying to scare you,’ said Grandad, looking at Roger’s reddening ears. It hadn’t sounded scary to Princess. If you had to be dead, it seemed a lot better to spend your time flying between the towers than lying underground. But she was bright enough, too, to know when to drop a subject. It was Grandad who spoke next, after a long pause broken only by the squeaking of the new shutter bars. When he did speak, it was as if something was on his mind. ‘We keep that name moving in the Overhead,’ he said, and it seemed to Princess that the wind in the shutter arrays above her blew more forlornly, and the everlasting clicking of the shutters grew more urgent. ‘He’d never have wanted to go home. He was a real linesman. His name is in the code, in the wind in the rigging and the shutters. Haven’t you ever heard the saying “A man’s not dead while his name is still spoken”?’

14 Likes

On my fantasy & sci-fi bookcase, just under two shelves are dedicated to his wonderful novels, spanning from victorian London through the modern age all the way to the Disk.

And now that small gap on the second shelf will forever remain empty.

3 Likes

Ist there a way to replace headers this way? My discourse installation prohibits iFrame embedding via the x-frame-options http header. If I try to change it this way, it will only add a second conflicting x-frame-options header. I also could not find any references to the default header in the discourse.conf of my nginx, but I don’t really know may way around there. Thanks!

Unfortunately, I think you need to add nginx’s “more headers” module. So that would be

exec: apt install nginx-extras

followed by the nginx.conf replace rule with a “more_remove_header” directive, I believe.

2 Likes

Kane, thanks for the fast Reply. I’ll look into this and post the exact solution for reference if it works.

I doubt that will work with our custom built NGINX in the image.

Simplest thing to do now would be a PR to add the module here: https://github.com/discourse/discourse_docker/blob/master/image/base/install-nginx

Then it will be picked up next image.

3 Likes