Basic Authentication with Nginx with proxy port (react/node app etc)


Requirements: apache2-utils or httpd-tools

Use htpasswd utility and create a .htpasswd file, see reference

htpasswd -c  /etc/nginx/.htpasswd usernamethatyouwant
chmod 644 /etc/nginx/.htpasswd

After that, just add lines in nginx conf

location / {
	auth_basic "Backend Area";
    auth_basic_user_file /etc/nginx/.htpasswd; ## path to your passwd file
	## ...
	## xyz code
	proxy_pass; ## Proxy port for your app
	proxy_set_header Authorization ""; ## DONT FORGET THIS. reset the auth header

Restart nginx now or test first using “nginx -t”

Fixing broken “screen options” in wordpress site

SELECT * from wp_usermeta where `meta_key` like 'edit_%_per_page'

So probably you chose “Number of items per page” as 1000 or 200 and now the page doesnt load anymore because your database ran out of memory.

If that is the case, run the above query on phpmysql or any other way, edit the numbers and fixed!