Servir arquivo estático

Deseja servir um arquivo estático na raiz do seu servidor Discourse?

Veja o que fazer. Na parte inferior do seu arquivo app.yml, na seção de comandos personalizados, faça algo assim:

## Lembre-se, esta é a sintaxe YAML - você só pode ter um bloco com um nome
run:
  - exec: echo "Início dos comandos personalizados"
  - file:
     path: /var/www/discourse/public/myfile.txt
     chmod: "+r"
     contents: |
       O conteúdo do arquivo vai aqui.
  - exec: echo "Fim dos comandos personalizados"

E execute . /launcher rebuild app

O arquivo estará então acessível em http://seuserver.com/myfile.txt

12 curtidas

What is an actual example of where one would want to do this?

2 curtidas

Personally i find this really useful. Not to mention that this kind of static file, gives you way more opportunities to use your imagination, files, maybe other website service that you can run as static – etc :smiley:

2 curtidas

I’m wondering what “stuff” limitations there are.

contents: |
       Stuff that's in the file goes here.

I imagine simple text strings work well enough, though I also imagine for this to be more useful, markup, links, images, etc. would be desired. I suspect that the more closely “stuff” approaches being a web page the more difficult it would be to not break.

@pfaffman what is your use case and what degree of complexity have you been able to do successfully?

1 curtida

This can also help verifying ownership of the site, e.g. with Google Webmaster Tools :slight_smile:

5 curtidas

Site ownership verification can be done with a meta tag in the head as well.

6 curtidas

Well, you’ve seen the actual examples that I know about. There are ways not to need it, but I’ve wanted to do this a few times and finally bothered to figure it out. :slight_smile:

3 curtidas

Very interesting and useful. Can this be tweaked to allow many files to be dumped into a folder for access? Say you want to make /var/www/discourse/public/img so that yourserver.tld/img/step_1.png can be served up easily and any number of subsequent files that are scp’d or uploaded in some way to the server?

1 curtida

Why would you use an application server to serve files? Wouldn’t it be cheaper to store and serve them elsewhere?

Not in my particular use case. I would prefer to do this for certain files that are specifically useful for admin purposes.

1 curtida

Estou usando o Cloudflare worker para este propósito:

2 curtidas

E quanto à hospedagem paga? Há alguma maneira de conseguir isso?

Preciso verificar a propriedade do domínio com o semrush para o meu projeto. Não quero que outros usuários do semrush auditem meu site.

Vou tentar este método mais tarde se o método original não funcionar :slight_smile:

Prefiro o que o médico diz :smiley:

1 curtida