Question

Can someone help to check this nginx conf file?

  • Posted January 26, 2020
  • Nginx

Hi, I feel something is not right in my nginx conf. file, on how I set the file request. Both old and new uploaded images to my website causing mixed content error. Many thanks!

etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name example.com www.example.com;
 

    # Added this to prevent man in the middle attacks
    add_header Strict-Transport-Security "max-age=31536000"; 

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root /var/www/example.com/html;
        index index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi, KDSys,

here is the System information

grandnode version: 4.50 Operating system: Linux 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 Machine name: grandnode-ubuntu-s-4vcpu-8gb-sgp1-01 ASP.NET info: v4.0.30319 Http request scheme: https Http scheme is https: True

Hi @nurbliss25,

I can confirm this is not related to your Nginx configuration but with your CMS application. Mixed content is created when you try to load your images,css,js files with http rather than https but try to open your website via HTTPS.

If you are using a framework,CMS usually there is a very easy way to resolve the matter however you need to google it. I can’t help you without knowing what you are using.

If you are using a custom built application, you’ll need to look into how and where these images or files are saved and change them from being server with http to https.

Regards, KDSys