Wednesday, April 3, 2019

nginx htpasswd for a django or proxy pass url location

When you try to configure htpasswd for a url location in nginx, you may get error connection time out, Incorrect Redirect or 404 not found. Most of the time reason is incorrectly configured proxy pass. If there is python or ruby based app where you have used proxy pass to access your web application, this error is very much common.

Tricky part if you try to set an htpasswd on login page but you do not land on My account page after login. It shows 404 not found and when you remove your htpasswd, this error does not show up after entering your login credentials.

So how can you set htpasswd successfully for a url location?

Solution :
Open nginx configuration file where you have set virtualhost for your domain. Add this location snippet in it. Add it below location / { ... }

Suppose you want to set htpasswd on login url i.e. http://domain.com/login. It should prompt htpasswd. Rest of the site should work fine without htpasswd.
  location /login {

        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host; 
        proxy_pass         http://127.0.0.1:8000$uri;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
Use $uri in proxy_pass attribute after port. You will not get 404 Not Found error after login.

Saturday, March 16, 2019

Linux Ubuntu Skype : Too Much Noise at Other End

If you are using Ubuntu operating system and other person is not able to hear you because of too much noise at his/her end. If every thing is fine at his/her end then this may be issue of your sounds settings. Here is a small tip to fix noise distortion for the person at opposite end.

In your Ubuntu Operating system, open Sound Settings. You can open this using right click at sound icon on panel or go to system settings and click on sound.
Here Under Input Tab, make the input volume selection minimum (7 to 8% of total value)
Make sure you have done this in Input tab, leave default settings for output tab.



This should solve your noise issue. 

Monday, February 11, 2019

wkhtmltopdf error : QXcbConnection: Could not connect to display

Solution :
Make sure you have installed wkhtmltopdf with patched QT version.
wkhtmltopdf --version
wkhtmltopdf 0.x.x (with patched qt)

 Download the latest wkhtmltopdf from here and install accordingly.