VPS侦探论坛

 找回密码
 注册
查看: 3780|回复: 6

magento2.4 安全证书整合

[复制链接]
发表于 2021-3-3 11:01:04 | 显示全部楼层 |阅读模式

本帖最后由 yisou 于 2021-3-3 11:03 编辑

这是我目前的代码:

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.cheapeyewear.net cheapeyewear.net;
        index index.php;
        set $MAGE_ROOT /home/wwwroot/www.cheapeyewear.net;

        root $MAGE_ROOT/pub;
        autoindex off;
        charset UTF-8;
        error_page 404 403 = /errors/404.php;
        #add_header "X-UA-Compatible" "IE=Edge";

        # Deny access to sensitive files
        location /.user.ini {
            deny all;
        }

        # PHP entry point for setup application
        location ~* ^/setup($|/) {
            root $MAGE_ROOT;
            location ~ ^/setup/index.php {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                fastcgi_pass   unix:/tmp/php-cgi.sock;

                fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
                fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=600";
                fastcgi_read_timeout 600s;
                fastcgi_connect_timeout 600s;

                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }

            location ~ ^/setup/(?!pub/). {
                deny all;
            }

            location ~ ^/setup/pub/ {
                add_header X-Frame-Options "SAMEORIGIN";
            }
        }

        # PHP entry point for update application
        location ~* ^/update($|/) {
            root $MAGE_ROOT;

            location ~ ^/update/index.php {
                fastcgi_split_path_info ^(/update/index.php)(/.+)$;
                fastcgi_pass   unix:/tmp/php-cgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO        $fastcgi_path_info;
                include        fastcgi_params;
            }

            # Deny everything but index.php
            location ~ ^/update/(?!pub/). {
                deny all;
            }

            location ~ ^/update/pub/ {
                add_header X-Frame-Options "SAMEORIGIN";
            }
        }

        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }

        location /pub/ {
            location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
                deny all;
            }
            alias $MAGE_ROOT/pub/;
            add_header X-Frame-Options "SAMEORIGIN";
        }

        location /static/ {
            # Uncomment the following line in production mode
            # expires max;

            # Remove signature of the static files that is used to overcome the browser cache
            location ~ ^/static/version {
                rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
            }

            location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
                add_header Cache-Control "public";
                add_header X-Frame-Options "SAMEORIGIN";
                expires +1y;

                if (!-f $request_filename) {
                    rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
                }
            }
            location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
                add_header Cache-Control "no-store";
                add_header X-Frame-Options "SAMEORIGIN";
                expires    off;

                if (!-f $request_filename) {
                   rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
                }
            }
            if (!-f $request_filename) {
                rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
            }
            add_header X-Frame-Options "SAMEORIGIN";
        }

        location /media/ {
            try_files $uri $uri/ /get.php$is_args$args;

            location ~ ^/media/theme_customization/.*\.xml {
                deny all;
            }

            location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
                add_header Cache-Control "public";
                add_header X-Frame-Options "SAMEORIGIN";
                expires +1y;
                try_files $uri $uri/ /get.php$is_args$args;
            }
            location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
                add_header Cache-Control "no-store";
                add_header X-Frame-Options "SAMEORIGIN";
                expires    off;
                try_files $uri $uri/ /get.php$is_args$args;
            }
            add_header X-Frame-Options "SAMEORIGIN";
        }

        location /media/customer/ {
            deny all;
        }

        location /media/downloadable/ {
            deny all;
        }

        location /media/import/ {
            deny all;
        }
        location /errors/ {
            location ~* \.xml$ {
                deny all;
            }
        }

        # PHP entry point for main application
        location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
            try_files $uri =404;
            fastcgi_pass   unix:/tmp/php-cgi.sock;
            fastcgi_buffers 1024 4k;

            fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
            fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
            fastcgi_read_timeout 600s;
            fastcgi_connect_timeout 600s;

            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        gzip on;
        gzip_disable "msie6";

        gzip_comp_level 6;
        gzip_min_length 1100;
        gzip_buffers 16 8k;
        gzip_proxied any;
        gzip_types
            text/plain
            text/css
            text/js
            text/xml
            text/javascript
            application/javascript
            application/x-javascript
            application/json
            application/xml
            application/xml+rss
            image/svg+xml;
        gzip_vary on;

        location ~ /.well-known {
            allow all;
        }

        # Banned locations (only reached if the earlier PHP entry point regexes don't match)
        location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
            deny all;
        }
    }





请问如何将下边的代码整合到你提供的magento.conf代码中?


server
    {
        listen 80;
        #listen [::]:80;
        server_name www.cheapeyewear.net cheapeyewear.net;
        index index.html index.htm index.php default.html default.htm default.php;
         #  root  /home/wwwroot/www.cheapeyewear.net;
         set $MAGE_ROOT /home/wwwroot/www.cheapeyewear.net;
        include rewrite/magento.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/www.cheapeyewear.net.log;
    }

server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name www.cheapeyewear.net cheapeyewear.net;
        index index.html index.htm index.php default.html default.htm default.php;
        # root  /home/wwwroot/www.cheapeyewear.net;
        set $MAGE_ROOT /home/wwwroot/www.cheapeyewear.net;
        ssl_certificate /usr/local/nginx/conf/ssl/www.cheapeyewear.net/fullchain.cer;
        ssl_certificate_key /usr/local/nginx/conf/ssl/www.cheapeyewear.net/www.cheapeyewear.net.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

        include rewrite/magento.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/www.cheapeyewear.net.log;
    }



美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2021-3-4 09:02:05 | 显示全部楼层


  1. server
  2.     {
  3.         listen 443 ssl http2;
  4.         #listen [::]:443 ssl http2;
  5.         server_name     lnmp.org www.lnmp.org;
  6.         index index.php;
  7.         set $MAGE_ROOT /home/wwwroot/lnmp.org;

  8.         ssl_certificate /usr/local/nginx/conf/ssl/lnmp.org.crt;
  9.         ssl_certificate_key /usr/local/nginx/conf/ssl/lnmp.org.key;
  10.         ssl_session_timeout 5m;
  11.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  12.         ssl_prefer_server_ciphers on;
  13.         ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  14.         ssl_session_cache builtin:1000 shared:SSL:10m;
  15.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  16.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  17.         root $MAGE_ROOT/pub;
  18.         autoindex off;
  19.         charset UTF-8;
  20.         error_page 404 403 = /errors/404.php;
  21.         #add_header "X-UA-Compatible" "IE=Edge";

  22.         # Deny access to sensitive files
  23.         location /.user.ini {
  24.             deny all;
  25.         }

  26.         # PHP entry point for setup application
  27.         location ~* ^/setup($|/) {
  28.             root $MAGE_ROOT;
  29.             location ~ ^/setup/index.php {
  30.                 fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  31.                 fastcgi_pass   unix:/tmp/php-cgi.sock;

  32.                 fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
  33.                 fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=600";
  34.                 fastcgi_read_timeout 600s;
  35.                 fastcgi_connect_timeout 600s;

  36.                 fastcgi_index  index.php;
  37.                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  38.                 include        fastcgi_params;
  39.             }

  40.             location ~ ^/setup/(?!pub/). {
  41.                 deny all;
  42.             }

  43.             location ~ ^/setup/pub/ {
  44.                 add_header X-Frame-Options "SAMEORIGIN";
  45.             }
  46.         }

  47.         # PHP entry point for update application
  48.         location ~* ^/update($|/) {
  49.             root $MAGE_ROOT;

  50.             location ~ ^/update/index.php {
  51.                 fastcgi_split_path_info ^(/update/index.php)(/.+)$;
  52.                 fastcgi_pass   unix:/tmp/php-cgi.sock;
  53.                 fastcgi_index  index.php;
  54.                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  55.                 fastcgi_param  PATH_INFO        $fastcgi_path_info;
  56.                 include        fastcgi_params;
  57.             }

  58.             # Deny everything but index.php
  59.             location ~ ^/update/(?!pub/). {
  60.                 deny all;
  61.             }

  62.             location ~ ^/update/pub/ {
  63.                 add_header X-Frame-Options "SAMEORIGIN";
  64.             }
  65.         }

  66.         location / {
  67.             try_files $uri $uri/ /index.php$is_args$args;
  68.         }

  69.         location /pub/ {
  70.             location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
  71.                 deny all;
  72.             }
  73.             alias $MAGE_ROOT/pub/;
  74.             add_header X-Frame-Options "SAMEORIGIN";
  75.         }

  76.         location /static/ {
  77.             # Uncomment the following line in production mode
  78.             # expires max;

  79.             # Remove signature of the static files that is used to overcome the browser cache
  80.             location ~ ^/static/version {
  81.                 rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
  82.             }

  83.             location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
  84.                 add_header Cache-Control "public";
  85.                 add_header X-Frame-Options "SAMEORIGIN";
  86.                 expires +1y;

  87.                 if (!-f $request_filename) {
  88.                     rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  89.                 }
  90.             }
  91.             location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  92.                 add_header Cache-Control "no-store";
  93.                 add_header X-Frame-Options "SAMEORIGIN";
  94.                 expires    off;

  95.                 if (!-f $request_filename) {
  96.                    rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  97.                 }
  98.             }
  99.             if (!-f $request_filename) {
  100.                 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  101.             }
  102.             add_header X-Frame-Options "SAMEORIGIN";
  103.         }

  104.         location /media/ {
  105.             try_files $uri $uri/ /get.php$is_args$args;

  106.             location ~ ^/media/theme_customization/.*\.xml {
  107.                 deny all;
  108.             }

  109.             location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  110.                 add_header Cache-Control "public";
  111.                 add_header X-Frame-Options "SAMEORIGIN";
  112.                 expires +1y;
  113.                 try_files $uri $uri/ /get.php$is_args$args;
  114.             }
  115.             location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  116.                 add_header Cache-Control "no-store";
  117.                 add_header X-Frame-Options "SAMEORIGIN";
  118.                 expires    off;
  119.                 try_files $uri $uri/ /get.php$is_args$args;
  120.             }
  121.             add_header X-Frame-Options "SAMEORIGIN";
  122.         }

  123.         location /media/customer/ {
  124.             deny all;
  125.         }

  126.         location /media/downloadable/ {
  127.             deny all;
  128.         }

  129.         location /media/import/ {
  130.             deny all;
  131.         }
  132.         location /errors/ {
  133.             location ~* \.xml$ {
  134.                 deny all;
  135.             }
  136.         }

  137.         # PHP entry point for main application
  138.         location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
  139.             try_files $uri =404;
  140.             fastcgi_pass   unix:/tmp/php-cgi.sock;
  141.             fastcgi_buffers 1024 4k;

  142.             fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
  143.             fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
  144.             fastcgi_read_timeout 600s;
  145.             fastcgi_connect_timeout 600s;

  146.             fastcgi_index  index.php;
  147.             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  148.             include        fastcgi_params;
  149.         }

  150.         gzip on;
  151.         gzip_disable "msie6";

  152.         gzip_comp_level 6;
  153.         gzip_min_length 1100;
  154.         gzip_buffers 16 8k;
  155.         gzip_proxied any;
  156.         gzip_types
  157.             text/plain
  158.             text/css
  159.             text/js
  160.             text/xml
  161.             text/javascript
  162.             application/javascript
  163.             application/x-javascript
  164.             application/json
  165.             application/xml
  166.             application/xml+rss
  167.             image/svg+xml;
  168.         gzip_vary on;

  169.         location ~ /.well-known {
  170.             allow all;
  171.         }

  172.         # Banned locations (only reached if the earlier PHP entry point regexes don't match)
  173.         location ~* (\.php$|\.phtml$|\.htaccess$|\.git) {
  174.             deny all;
  175.         }
  176.     }
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2021-3-5 13:07:59 | 显示全部楼层

一会能访问, 一会出现下边2种问题

Autoload error

We can't read some files that are required to run the Magento application. This usually means file permissions are set incorrectly.
或是
no input file specified

权限问题改了, 也不知哪不对。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2021-3-5 19:27:01 | 显示全部楼层



yisou 发表于 2021-3-5 13:07
一会能访问, 一会出现下边2种问题

Autoload error

1 配置文件中目录是否正确

2 检查网站目录和文件权限及属主属组

3 去除防跨目录设置
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2021-3-6 06:26:29 | 显示全部楼层

去除防跨目录设置
请问这个如何设置
谢谢军哥

军哥运维代购:http://shop63846532.taobao.com/

发表于 2021-3-6 13:03:36 | 显示全部楼层

yisou 发表于 2021-3-6 06:26
去除防跨目录设置
请问这个如何设置
谢谢军哥

官网:https://lnmp.org 搜索:防跨目录设置
都能找到
 楼主| 发表于 2021-3-7 17:38:57 | 显示全部楼层

非常感谢两位的帮助!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-21 02:34 , Processed in 0.027507 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表