Tag: Nginx Configuration

  • 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 ~ /\.ht {
            deny  all;
        }
    
        error_page 302  /302.html;
        location = /302.html {
            root  /home/free.bizhat.com/error;
        }
    
        error_page 404 /404.html;
        location = /404.html {
              root  /home/free.bizhat.com/error;
        }
    }
    

    Nginx

  • Magento 1.9 Nginx Configuration

    Here is Nginx + php-fpm config for Magento 1.9 on Ubuntu 16.04/Debian 9.

    server {
        listen 80;
    
        server_name mysite.com www.mysite.com;
        root /home/mysite.com/public_html/;
    
        listen 443 ssl http2;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain1.pem;
        ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey1.pem;
    
        location / {
            index   index.html  index.php; 
            try_files $uri $uri/ @handler; 
            expires 30d; 
        }
    
        ## These locations would be hidden by .htaccess normally
        location /app/                { deny all; }
        location /includes/           { deny all; }
        location /lib/                { deny all; }
        location /media/downloadable/ { deny all; }
        location /pkginfo/            { deny all; }
        location /report/config.xml   { deny all; }
        location /var/                { deny all; }
    
    
        ## Disable .htaccess and other hidden files
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }
    
        location @handler { 
            rewrite / /index.php;
        }
    
        location ~ \.php/ { 
            rewrite ^(.*\.php)/ $1 last;
        }
    
        location ~ \.php$ { 
            if (!-e $request_filename) { 
                rewrite / /index.php last; 
            } 
    
            expires         off; 
            fastcgi_pass    unix:/run/php/php7.0-fpm.sock;
            include         snippets/fastcgi-php.conf;
        }
    }