·   ·  5 posts
  •  ·  33 friends

NGINX Website Configuration


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;
# Cache Static Files
     location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
     expires 365d;
     proxy_buffer_size          128k;
    proxy_buffers              4 256k;
     proxy_busy_buffers_size    256k;
    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
  • 1111
  • More
Comments (4)
    Login or Join to comment.