【发布时间】:2020-12-01 15:36:54
【问题描述】:
我有一个 Magento 应用程序,我尝试在 CentOS 7 服务器上运行它。我可以在浏览器中访问应用程序。但是,找不到像css和js这样的文件,因为该应用程序在服务器上的根位置已添加到url中。
例如,一个文件位于:https://www.example.com/css/my_file.css
但浏览器请求它来自:https://www.example.com/usr/share/nginx/application_name/css/my_file.css
我怎样才能得到正确的路径?
我安装了 Nginx 版本 1.16.1。 Nginx 正在侦听端口 8080,因为它位于侦听端口 80 的 Varnish 后面。这是虚拟主机:
server {
listen 8080 default_server;
server_name www.example.com;
root /usr/share/nginx/application_name;
index index.php;
location ^~ /app/ { return 403; }
location ^~ /db/ { return 403; }
location ^~ /dev/ { return 403; }
location ^~ /downloader/pearlib { return 403; }
location ^~ /downloader/template { return 403; }
location ^~ /downloader/Maged { return 403; }
location ~* ^/errors/.+\.xml { return 403; }
location ^~ /includes/ { return 403; }
location ^~ /lib/ { return 403; }
location ^~ /media/downloadable/ { return 403; }
location ^~ /shell/ { return 403; }
location ^~ /var/ { return 403; }
location ^~ /varnish/ { return 403; }
location ^~ /vendor/ { return 403; }
location ~ .phtml$ { return 403; }
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE base;
fastcgi_param MAGE_RUN_TYPE website;
include fastcgi_params;
fastcgi_read_timeout 90;
}
}
【问题讨论】: