Servire file statico

Vuoi servire un file statico alla radice del tuo server Discourse?

Ecco cosa fare. Nella parte inferiore del tuo file `app.yml, nella sezione dei comandi personalizzati, fai qualcosa di simile a questo:

## Ricorda, questa è la sintassi YAML: puoi avere solo un blocco con un nome
run:
  - exec: echo "Inizio dei comandi personalizzati"
  - file:
     path: /var/www/discourse/public/myfile.txt
     chmod: "+r"
     contents: |
       Il contenuto del file va qui.
  - exec: echo "Fine dei comandi personalizzati"

E poi esegui . /launcher rebuild app
Il file sarà quindi accessibile all’indirizzo http://yourserver.com/myfile.txt

12 Mi Piace

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

2 Mi Piace

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 Mi Piace

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 Mi Piace

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

5 Mi Piace

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

6 Mi Piace

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 Mi Piace

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 Mi Piace

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 Mi Piace

Sto usando Cloudflare worker per questo scopo:

2 Mi Piace

E per quanto riguarda l’hosting a pagamento? C’è un modo per ottenerlo?

Devo verificare la proprietà del dominio con Semrush per il mio progetto. Non voglio che altri utenti di Semrush eseguano l’audit del mio sito.

Proverò questo metodo più tardi se il metodo originale non dovesse funzionare :slight_smile:

Preferisco quello che dice il dottore :smiley:

1 Mi Piace