Software
My Mautic version is: 2.16.2
My PHP version is: 7.3.17-1+ubuntu18.04.1+deb.sury.org+1
Problem
My problem is:
I have 2 problems that I think are related somehow. Tracking pixels and JS code load fine in the browser, but their http code is 404, same for the forms, but for these, they don’t even work when I try to embed them in a website.
curl -I https://mymauticinstall.com/mtc.js
HTTP/2 404
server: nginx
content-type: application/javascript; charset=utf-8
vary: Accept-Encoding
set-cookie: 7bb85555927bdb8d66d3d0ee6d04ad51=ap53f7bm8auttj8o1hqqlso3aa; path=/; secure; HttpOnly
cache-control: no-cache
date: Mon, 04 May 2020 22:41:30 GMT
This file when loaded in a browser shows the correct content, but it also shows a 404 error, same for the JS that loads the forms. But in the case of the forms as I said, it prevents them from working completely, so nothing gets rendered.
These errors are showing in the log:
2020/05/04 17:39:49 [debug] 28961#28961: *1 http filename: “/home/forge/mymauticinstall.com/public/mtc.js”
2020/05/04 17:39:49 [debug] 28961#28961: *1 add cleanup: 00005627D28D57B8
2020/05/04 17:39:49 [error] 28961#28961: *1 open() “/home/forge/mymauticinstall.com/public/mtc.js” failed (2: No such file or directory), client: 179.6.209.113, server: mymauticinstall.com, request: “HEAD /mtc.js HTTP/2.0”, host: “mymauticinstall.com”
2020/05/04 17:39:49 [debug] 28961#28961: *1 http finalize request: 404, “/mtc.js?” a:1, c:1
2020/05/04 17:39:49 [debug] 28961#28961: *1 http special response: 404, “/mtc.js?”
2020/05/04 17:39:49 [debug] 28961#28961: *1 internal redirect: “/index.php?”
Steps I have tried to fix the problem:
I’ve searched the internet multiple times, tried several different configurations and tried to debug this on my own. Searched the forums and github for answers. Also tried stackoverflow and other similar sites. Nothing.
Current config:
add_header ‘Access-Control-Allow-Origin’ “*”;
# redirect index.php to root
rewrite ^/index.php/(.*) /$1 permanent;
# Allow the filemanager to work
location ~ ^/app/bundles/CoreBundle/Assets/js/libraries/ckeditor/filemanager/connectors/php/filemanager.php$ {
allow all;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
include fastcgi_params;
}
# Deny everything else in /app folder except Assets folder in bundles
location ~ /app/bundles/.*/Assets/ {
allow all;
access_log off;
}
location ~ /app/ { deny all; }
# Deny everything else in /addons or /plugins folder except Assets folder in bundles
location ~ ^/(addons|plugins)/.*/Assets/ {
allow all;
access_log off;
}
location ~ ^/(addons|plugins)/ { deny all; }
# Deny all php files in themes folder
location ~* ^/themes/(.*)\.php {
deny all;
}
# Deny yml, twig, markdown, init file access
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
# Except .well-known to allow for certbot to issue and renew certificates
location ~ /\.(?!well-known).* {
deny all;
access_log off;
log_not_found off;
}
# Deny all grunt, composer files
location ~* (Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny access to any files with a .php extension in the uploads directory
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~ ^/mtc.js {
default_type "application/javascript";
try_files $uri $uri/ /index.php$is_args$args;
}
location ~* ^/media/js/$ {
add_header 'Cache-Control' public;
expires 7d;
}
location ~ \.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
allow all;
try_files $uri $uri/ /index.php$is_args$args;
}
# Set cache expiry time
location ~* \.(jpg|jpeg|png|ico|css)$ {
expires 365d;
}
location ~* \.(pdf)$ {
expires 30d;
}
# Add X-Robots-Tag header to login page to prevent bots from indexing or following
add_header X-Robots-Tag "noindex, nofollow";
Any help is appreciated, thanks.