Nginx Rails Origin header didn’t match request.base_url

Nginx Web Server

After installing SSL on Nginx server, rails application login page stopped working. On log file (log/production.log), found following error HTTP Origin header (https://domain.com) didn’t match request.base_url (http://domain.com) The Nginx config used was upstream app { server unix:/var/www/public/shared/sockets/unicorn.sock fail_timeout=0; } server { listen 443 ssl; root /var/www/public; ssl_certificate /etc/ssl/ssl.crt; ssl_certificate_key /etc/ssl/ssl.key; server_name domain.com; try_files $uri/index.html $uri … Read more

Docker Nginx Proxy

Docker Nginx Proxy allow you to run multiple docker containers on same server behind nginx proxy. This is done using https://github.com/jwilder/nginx-proxy To do this, you need a server with port 80 and 443 unused. To setup nginx proxy, run following cd /root/ git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git cd docker-compose-letsencrypt-nginx-proxy-companion cp .env.sample .env ./start.sh This will start nginx … Read more

Nginx Disable Access log

Nginx Web Server

On a high traffic web site, i want to disable access log as we are hitting I/O Limit. Since we don’t use this access log for anything now, there is no point keep writing it to a file. To disable, you need to add following to server entry for your web site. access_log off; Here … Read more

Enable Directory Listing in Nginx

To enable directory listing in Nginx, add following to server configuration. autoindex on; Example server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; autoindex on; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; proxy_read_timeout 600; fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_intercept_errors on; fastcgi_buffers … Read more

Nginx 413 Request Entity Too Large

On Nginx server, when uploading large file, i get error 413 Request Entity Too Large On nginx error log 2018/10/10 18:15:34 [error] 25787#0: *184 client intended to send too large body: 31354043 bytes, client: 15.17.7.27, server: _, request: “POST /phpmyadmin/import.php HTTP/1.1”, host: “13.16.28.19” To fix, edit nginx config for the web site, under the server … Read more

Nginx CloudFlare restore real ip

When using Nginx Behind Cloudflare, logs and web applications show Cloudflare sever IP instead of visitor IP. To fix this, edit Inside “http” section, add You can get updated list of CloudFlare IPs from https://www.cloudflare.com/ips Restart Nginx with Example Nginx Config https://gist.github.com/serverok/fef5c76bf96f8e016bf64095da4a64dc Back to Nginx

Disable Access to a folder in Nginx

To disable access to folder /admin in Nginx, add following to server block of your web site. location /admin { deny all; return 404; } To disable access to some common virtual control software, use location ~ /\.ht {return 404;} location ~ /\.svn/ {return 404;} location ~ /\.git/ {return 404;} location ~ /\.hg/ {return 404;} … Read more

Nginx Proxy SSL Verification

When using Nginx as a reverse proxy, you may need to handle SSL verification requests. Passing this request to the backend server may not do any good as back-end servers usually only handle application requests. To handle SSL validation requests, use the following Nginx Configuration Now restart Nginx You can get SSL with the following … Read more

Nginx wildcard virtualhost

wildcard virtual host allow you to host multiple web sites with one configuration file. Here is what i use for bizhat.com free hosting sub domains. server { listen 167.114.61.119:80; server_name *.bizhat.com; autoindex on; access_log /var/log/nginx/free_access.log; error_log /var/log/nginx/free_error.log; root /home/vhosts/$host; index index.html index.htm default.htm default.html; location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires max; } location ~ … Read more

Nginx configuration for aMember

Here is Nginx configuration for aMember script location ~* ^/amember/.*\.(js|ico|gif|jpg|png|css|swf|csv)$ {} location ~* ^/amember/setup/index.php$ { try_files not-existing-file @php; } location ~* ^/amember/js.php { try_files not-existing-file @php; } location ~* ^/amember/index.php$ { try_files not-existing-file @php; } location ~* ^/amember/public.php$ { try_files not-existing-file @php; } location ~* ^/amember/public { rewrite ^.*$ /amember/public.php; } location ~* ^/amember/setup { … Read more

Nginx

Nginx is a powerful open source web server that is known for its high performance, stability, and flexibility. It is used by millions of websites around the world, and it is a popular choice for web developers and system administrators who need a reliable and efficient way to serve web content. Install Nginx Nginx Tricks … Read more