Configuring nginx to run Magento ,Magento SSL HTTPS SSL Certificates‎

server {
    listen       443;
    server_name  magento.com;
    index index.php index.html index.htm;
    root  /var/www/magento.com;

    ssl                  on;
    ssl_certificate      /etc/nginx/magento.com.pem;
    ssl_certificate_key  /etc/nginx/magento.com.key;

    rewrite ^/$ http://magento.com/ permanent;

    location / {
        if (-f $request_filename) {
               expires 30d;
               break;
        }
        if (!-e $request_filename) {
               rewrite ^(.+)$ /index.php last;
        }
    }

    location ~ .*\.php?$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include fastcgi_params;
    }

     location /app/etc {
         deny all;
     }

    access_log  /var/log/nginx/magento.com-ssl.access.log  main;
    error_log   /var/log/nginx/magento.com-ssl.error.log;

}

 

 

 

***********************************************************

server {
    # Listen on port 80 as well as post 443 for SSL connections.
    listen 80;
    listen 443 default ssl;
 
    server_name yourdomain.com www.yourdomain.com;
 
    # Specify path to your SSL certificates.
    ssl_certificate /etc/nginx/certificates/yourcertificate.crt;
    ssl_certificate_key /etc/nginx/certificates/yourcertificate.key;
 
    # Path to the files in which you wish to
    # store your access and error logs.
    access_log /path/to/your/logs/access_log;
    error_log /path/to/your/logs/error_log;
 
    # If the site is accessed via yourdomain.com
    # automatically redirect to www.yourdomain.com.
    if ($host = 'yourdomain.com' ) {
        rewrite ^/(.*)$ http://www.yourdomain.com/$1permanent;
    }
 
    root /path/to/magento;
 
    location / {
        index index.html index.php;
        try_files $uri $uri/ @handler;
    }
 
    # Deny access to specific directories no one
    # in particular needs access to anyways.
    location /app/ { deny all; }
    location /includes/ { deny all; }
    location /lib/ { deny all; }
    location /media/downloadable/ { deny all; }
    location /pkginfo/ { deny all; }
    location /report/config.xml { deny all; }
    location /var/ { deny all; }
 
    # Allow only those who have a login name and password
    # to view the export folder. Refer to /etc/nginx/htpassword.
    location /var/export/ {
        auth_basic "Restricted";
        auth_basic_user_file htpasswd;
        autoindex on;
    }
 
    # Deny all attempts to access hidden files
    # such as .htaccess, .htpasswd, etc...
    location ~ /\. {
         deny all;
         access_log off;
         log_not_found off;
    }
 
    # This redirect is added so to use Magentos
    # common front handler when handling incoming URLs.
    location @handler {
        rewrite / /index.php;
    }
 
    # Forward paths such as /js/index.php/x.js
    # to their relevant handler.
    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }
 
    # Handle the exectution of .php files.
    location ~ .php$ {
        if (!-e $request_filename) {
            rewrite / /index.php last;
        }
        expires off;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param HTTPS $fastcgi_https;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param MAGE_RUN_CODE default;
        fastcgi_param MAGE_RUN_TYPE store;
        include fastcgi_params;
    }
}

转载于:https://www.cnblogs.com/kaixin110/archive/2012/09/18/2692340.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值