wordpress-playground icon indicating copy to clipboard operation
wordpress-playground copied to clipboard

Latest NGINX equivalent for .htaccess to host a playground

Open 0aveRyan opened this issue 1 year ago • 3 comments

Just dropping the config I used for an Nginx box, few of these would probably be good for self-hosting docs once that's more realistic in the future.

	location ~* .wasm$ {
	  types {
	    application/wasm wasm;
	  }
	}

	location ~* .data$ {
	  types {
	    application/octet-stream data;
	  }
	}

	location /scope:.* {
	  rewrite ^scope:.*?/(.*)$ $1 last;
	}

	# Enable Multiviews equivalent
	location / {
	    try_files $uri $uri/ @rewrite;
	}

	location @rewrite {
	    rewrite ^/(.*)$ /index.php?q=$1;
	}

	# Add gzip encoding for .gz files
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

	# Remove ETag and set Cache-Control for index.html
	location ~* ^/index\.html$ {
	    add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
	    add_header Pragma "no-cache";
	    add_header Expires "Wed, 11 Jan 1984 05:00:00 GMT";
	}

	# Set Access-Control-Allow-Origin and remove ETag, set Cache-Control for specific files
	location ~* ^/(index\.js|blueprint-schema\.json|wp-cli\.phar)$ {
	    add_header Access-Control-Allow-Origin "*";
	    add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
	    add_header Pragma "no-cache";
	    add_header Expires "Wed, 11 Jan 1984 05:00:00 GMT";
	}

0aveRyan avatar Mar 10 '24 19:03 0aveRyan

Thank you so much @0aveRyan! Would you be up for proposing it as a PR for the NGINX configuration documentation section? I know that section is a bit obscured at the moment, the documentation will get a structural overhaul in a short-to-medium-term future to make that section more visible and accessible.

adamziel avatar Mar 11 '24 09:03 adamziel

@adamziel happy to add a PR. Had a lot of fun tinkering yesterday! I have a small short list I need to review of issues and perhaps open some here.

Partially wanted to start in an issue to see what kind of appetite there was for docs/etc. I know things are moving fast and didn't know if any other updates were in the works.

Also, noting for anyone who like me who does not breathe the nuances of NGINX and Apache every day... AI chatbots do fairly well going from one syntax to the other 😎

https://chat.openai.com/share/3b101d51-9e22-49f6-952f-6fcee3ef4344

0aveRyan avatar Mar 11 '24 14:03 0aveRyan

@0aveRyan There's quite a bit of an appetite for docs! See the following issues:

  • https://github.com/WordPress/blueprints/issues/64
  • https://github.com/WordPress/wordpress-playground/issues/772
  • https://github.com/WordPress/wordpress-playground/issues/1074

adamziel avatar Mar 11 '24 23:03 adamziel