Welcome to Centmin Mod Community
Register Now

Magneto Nginx rule

Discussion in 'Introductions' started by Manoj malviya, Dec 21, 2019.

  1. Manoj malviya

    Manoj malviya New Member

    19
    1
    3
    Dec 21, 2019
    Ratings:
    +1
    Local Time:
    12:24 PM
    1.17.6
    10.3.20
    I have tried to host Magneto 2.3.3 on Centiminmod by using this rule

    Don't know what I am missing but I am not able to upload image from backend in product section.

    Attacing error image[​IMG]

    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html

    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    # listen 80;
    # server_name magento.game5.ml;
    # return 301 $scheme://www.magento.game5.ml$request_uri;
    # }

    server {

    server_name magento.game5.ml www.magento.game5.ml;

    access_log /home/nginx/domains/magento.game5.ml/log/access.log combined buffer=256k flush=5m;
    error_log /home/nginx/domains/magento.game5.ml/log/error.log;

    #include /usr/local/nginx/conf/autoprotect/magento.game5.ml/autoprotect-magento.game5.ml.conf;
    set $MAGE_ROOT /home/nginx/domains/magento.game5.ml/public;
    root $MAGE_ROOT/pub;
    include /usr/local/nginx/conf/503include-main.conf;

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

    # PHP entry point for setup application
    location ~* ^/setup($|/) {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {
    include /usr/local/nginx/conf/php.conf;
    }

    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)(/.+)$;
    include /usr/local/nginx/conf/php_magento.conf;
    }

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

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

    location / {
    include /usr/local/nginx/conf/503include-only.conf;
    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)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires 30d;
    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
    }
    }
    location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires +1y;

    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 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/?(.*)$ /static.php?resource=$1 last;
    }
    }
    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 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)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires 30d;
    try_files $uri $uri/ /get.php$is_args$args;
    }
    location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    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;
    }

    # Deny cron and files with the obvious names. favorite entry points for hackers and script kiddie
    location ~* ^/(cron|phpminiadmin|pma|sqlyog|adminer.+)\.php { deny all; }

    # Deny auth and composer
    location ~ (auth|package|composer)\.(json|lock)$ { deny all; }

    # PHP entry point for main application
    location ~ (index|get|static|report|404|503|health_check)\.php$ {
    try_files $uri =404;
    add_header X-Processing-Time $request_time always;
    add_header X-Request-ID $request_id always;
    add_header Strict-Transport-Security $mag_hstsheader always;
    add_header X-UA-Compatible 'IE=Edge,chrome=1';
    add_header Link "<$scheme://$http_host$request_uri>; rel=\"canonical\"" always;
    fastcgi_buffers 1024 4k;

    fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
    fastcgi_param PHP_VALUE "memory_limit=4096M \n max_execution_time=18000 \n max_input_time=18000";
    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;
    include /usr/local/nginx/conf/503include-only.conf;
    include /usr/local/nginx/conf/php.conf;
    }

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

    #include /usr/local/nginx/conf/pre-staticfiles-local-magento.game5.ml.conf;
    include /usr/local/nginx/conf/pre-staticfiles-global.conf;
    #include /usr/local/nginx/conf/staticfiles.conf;
    #include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_server.conf;
     
  2. eva2000

    eva2000 Administrator Staff Member

    43,441
    9,861
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,228
    Local Time:
    4:54 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    welcome @Manoj malviya to Centmin Mod Community. Best place to ask is in dedicated subforum for this topic at hand at https://community.centminmod.com/forums/ecommerce-shopping-cart-usage.35/ and magento forum prefix filtered threads at https://community.centminmod.com/forums/ecommerce-shopping-cart-usage.35/?prefix_id=62 might give you a better clue.

    There's 6 steps to learning more about Centmin Mod ;) And to modifying config files and manage services more quickly, check out Centmin Mod Command Shortcuts.

    Might also be interested in reading up on latest LEMP stack comparison benchmarks tagged here.

    You might want to try the 123.09beta01 build as it will be next stable release and well has alot of improvements if you check 2nd post change log at Beta Branch - Centmin Mod .09 beta branch Testing. And you can share your initial install times here.

    Threads you might want to participate in ;)

    Quick Tips


    Threads & Info To Bookmark



    Threads to read, pages to bookmark and threads to watch/subscribe to get to know Centmin Mod would include:

    Centmin Mod Insights Forum



    The Centmin Mod Insights forums digs deeper into the inner workings of Centmin Mod so some useful threads in this forum include:

    Security Related Developments



    A few security related developments you might be interested reading about

    Premium Membership


    Centmin Mod Donations



    You now can show your love and support for Centmin Mod via
     
  3. eva2000

    eva2000 Administrator Staff Member

    43,441
    9,861
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,228
    Local Time:
    4:54 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  4. Manoj malviya

    Manoj malviya New Member

    19
    1
    3
    Dec 21, 2019
    Ratings:
    +1
    Local Time:
    12:24 PM
    1.17.6
    10.3.20
    Here it is

    Thanks

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    # listen 80;
    # server_name magento.game5.ml;
    # return 301 $scheme://www.magento.game5.ml$request_uri;
    # }
    
    server {
    
    server_name magento.game5.ml www.magento.game5.ml;
    
    access_log /home/nginx/domains/magento.game5.ml/log/access.log combined buffer=256k flush=5m;
    error_log /home/nginx/domains/magento.game5.ml/log/error.log;
    
    #include /usr/local/nginx/conf/autoprotect/magento.game5.ml/autoprotect-magento.game5.ml.conf;
    set $MAGE_ROOT /home/nginx/domains/magento.game5.ml/public;
    root $MAGE_ROOT/pub;
    include /usr/local/nginx/conf/503include-main.conf;
    
    index index.php;
    autoindex off;
    charset UTF-8;
    error_page 404 403 = /errors/404.php;
    #add_header "X-UA-Compatible" "IE=Edge";
    
    # PHP entry point for setup application
    location ~* ^/setup($|/) {
    root $MAGE_ROOT;
    location ~ ^/setup/index.php {
    include /usr/local/nginx/conf/php.conf;
    }
    
    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)(/.+)$;
    include /usr/local/nginx/conf/php_magento.conf;
    }
    
    # Deny everything but index.php
    location ~ ^/update/(?!pub/). {
    deny all;
    }
    
    location ~ ^/update/pub/ {
    add_header X-Frame-Options "SAMEORIGIN";
    }
    }
    
    location / {
    include /usr/local/nginx/conf/503include-only.conf;
    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)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires 30d;
    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 last;
    }
    }
    location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires +1y;
    
    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 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/?(.*)$ /static.php?resource=$1 last;
    }
    }
    if (!-f $request_filename) {
    rewrite ^/static/?(.*)$ /static.php?resource=$1 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)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    add_header X-Frame-Options "SAMEORIGIN";
    expires 30d;
    try_files $uri $uri/ /get.php$is_args$args;
    }
    location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
    add_header Cache-Control "public";
    add_header Access-Control-Allow-Origin *;
    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;
    }
    
    # Deny cron and files with the obvious names. favorite entry points for hackers and script kiddie
    location ~* ^/(cron|phpminiadmin|pma|sqlyog|adminer.+)\.php { deny all; }
    
    # Deny auth and composer
    location ~ (auth|package|composer)\.(json|lock)$ { deny all; }
    
    # PHP entry point for main application
    location ~ (index|get|static|report|404|503|health_check)\.php$ {
    try_files $uri =404;
    add_header X-Processing-Time $request_time always;
    add_header X-Request-ID $request_id always;
    add_header Strict-Transport-Security $mag_hstsheader always;
    add_header X-UA-Compatible 'IE=Edge,chrome=1';
    add_header Link "<$scheme://$http_host$request_uri>; rel=\"canonical\"" always;
    fastcgi_buffers 1024 4k;
    
    fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
    fastcgi_param PHP_VALUE "memory_limit=4096M \n max_execution_time=18000 \n max_input_time=18000";
    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;
    include /usr/local/nginx/conf/503include-only.conf;
    include /usr/local/nginx/conf/php.conf;
    }
    
    # Banned locations (only reached if the earlier PHP entry point regexes don't match)
    location ~* (\.php$|\.htaccess$|\.git) {
    deny all;
    }
    
    #include /usr/local/nginx/conf/pre-staticfiles-local-magento.game5.ml.conf;
    include /usr/local/nginx/conf/pre-staticfiles-global.conf;
    #include /usr/local/nginx/conf/staticfiles.conf;
    #include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_server.conf;
     
  5. eva2000

    eva2000 Administrator Staff Member

    43,441
    9,861
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,228
    Local Time:
    4:54 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x