Servir archivo estático

¿Quieres servir un archivo estático en la raíz de tu servidor Discourse?

Esto es lo que debes hacer. En la parte inferior de tu archivo app.yml, en la sección de comandos personalizados, haz algo como esto:

## Recuerda, esta es sintaxis YAML: solo puedes tener un bloque con un nombre
run:
  - exec: echo "Inicio de comandos personalizados"
  - file:
     path: /var/www/discourse/public/myfile.txt
     chmod: "+r"
     contents: |
       El contenido del archivo va aquí.
  - exec: echo "Fin de comandos personalizados"

Lanza . /launcher rebuild app.

El archivo será accesible en http://tuserver.com/myfile.txt.

12 Me gusta

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

2 Me gusta

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 Me gusta

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 me gusta

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

5 Me gusta

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

6 Me gusta

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 Me gusta

Muy interesante y útil. ¿Se puede ajustar para permitir volcar muchos archivos en una carpeta para su acceso? Por ejemplo, si deseas crear /var/www/discourse/public/img para que yourserver.tld/img/step_1.png pueda servirse fácilmente, junto con cualquier número de archivos posteriores que se copien mediante scp o se suban de alguna otra forma al servidor?

1 me gusta

¿Por qué usarías un servidor de aplicaciones para servir archivos? ¿No sería más barato almacenarlos y servirlos en otro lugar?

No en mi caso de uso específico. Preferiría hacer esto para ciertos archivos que son específicamente útiles con fines administrativos.

1 me gusta

Estoy usando Cloudflare worker para este propósito:

2 Me gusta

¿Qué hay del alojamiento de pago? ¿Alguna forma de lograr esto?

Necesito verificar la propiedad del dominio con Semrush para mi proyecto. No quiero que otros que usan Semrush auditen mi sitio.

lo intentaré más tarde si el método original no funciona :slight_smile:

Prefiero lo que dice el doctor :smiley:

1 me gusta