·   · 9 posts

NGINX Website Configuration

Hi,

I am testing UNA on NGINX and have a problem loading some images, here is my config file for mywebsite. 

Please can someone help me correct this config to show images?


server {
    listen         80;
    listen         443 ssl;
    # add Strict-Transport-Security to prevent man in the middle attacks
    add_header Strict-Transport-Security "max-age=31536000";
    server_name    mywebsite.com;
    root           /var/www/mywebsite;
    index          index.php;
 
  location ~* \.php$ {
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME     $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE mywebsite;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /mywebsite;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param HTTPS $https;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
  }
 
location / {
    index index.html index.htm index.php;
 
    rewrite "^/page/(.*)$" /page.php?i=$1 last;
    rewrite "^/m/(.*)$" /modules/index.php?r=$1 last;
    rewrite "^/s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)" /storage.php?o=$1&f=$2 last;
 
    if (!-e $request_filename ) {
        rewrite  ^/(.+)$   /r.php?_q=$1  last;
        break;
    }
 }
 
# Cache Static Files
     location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
     expires 365d;
     }
 
# PROXY SETTINGS
     proxy_buffer_size          128k;
    proxy_buffers              4 256k;
     proxy_busy_buffers_size    256k;
 
# GZIP COMPRESSION
    gzip on;
    gzip_proxied any;
    gzip_types text/plain text/xml text/css application/x-javascript;
    gzip_vary on;
    gzip_disable “MSIE [1-6]\.(?!.*SV1)”;
 
# SSL Certificate Settings
    ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
     ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem; # managed by Certbot
}
0 0 0 0 0 0
  • 139
Comments (4)
  • Alex T⚜️ please can you comment, I have the rewrite rules as per your suggestions.


    0 0 0 0 0 0
    • I would recommend the following rule for static files cache:

      location ~* ^(/cache_public/|/plugins_public/|/modules/|/studio/|/template/).+\.(jpg|jpeg|gif|css|png|js|ico|svg|eot|ttf|woff|woff2|)$ {

      Instead of:

      location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {

      0 0 0 0 0 0
      • Thank you, will try that.

        0 0 0 0 0 0
        • It worked perfectly, thank you for your help. It is always good to have the assistance of a true professional.

          0 0 0 0 0 0
        Not logged in users can't 'Comments Post'.
        Share
        Labels:
        Category:
        Created:
        Updated:
        Featured Posts

        UNA - Social Media Software Framework

        Close