dreamfactorysoftware / openshift-dreamfactory-cartridge

OpenShift cartridge for DreamFactory
10 stars 8 forks source link

htaccess on openshift #2

Closed mm108 closed 8 years ago

mm108 commented 8 years ago

Just used the cartridge to install on openshift and it went pretty smooth - thanks!!! I installed it with the following command(with scaling) : rhc create-app dreamfactory http://cartreflect-claytondev.rhcloud.com/github/dreamfactorysoftware/dreamfactory-openshift-cartridge -s

Just a small question as both openshift and dreamfactory are new to me. What should be the location of htaccess file in dreamfactory application in openshift and 2ndly - any specific htaccess directives or commands that would help improve the performance or add to the security? Thanks a ton once again for the wonderful work.

mm108 commented 8 years ago

I managed to figure this out. The web root of df application I think is \df\public\dreamfactory\dist. I found the htaccess file and it seems to be tuned for dreamfactory. Please consider this request closed. Thanks once again and happy new year :-)

chris-gunawardena commented 8 years ago

Hi m-menon, This openshift cartridge uses Nginx instead of Apache so .htacess file won't have any effect.

You can find the related Nginx config files in ~/dreamfactory/conf/nginx.conf and ~/dreamfactory/conf/nginx_http.conf when deployed or in https://github.com/dreamfactorysoftware/openshift-dreamfactory-cartridge/tree/master/conf

mm108 commented 8 years ago

hi chris,

Thanks for the pointers. This is just the 2nd day that I am dealing with nginx so I am a little lost :-) I just need 2 little things to be done

1) Allow only HTTPS (I have already installed the cert for the domain/application) 2) Set up HSTS for the site. I guess the HSTS set up would be something like this server { listen 443 ssl; server_name example.domain.com; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";

But as for forcing / allowing only https/ssl, I am hesitant because I wouldn't want to mess up the nginx_http.conf file. I may end up having to reinstall dreamfactory on openshift once again.

Thanks, M&M

df-jablan commented 8 years ago

You can force SSL pretty easily with something like this:

server {
        listen 80;
        server_name example.domain.com;
        return 301 https://$host$request_uri;
}

server {
        listen 443 ssl;
        server_name example.domain.com;
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
        ...
}
mm108 commented 8 years ago

sori about responding so late but do I need to edit both nginx.conf and nginx_http.conf?

I thought I should confirm this as I am dealing with nginx for the first time ever so wouldn't want to take any chances :-)

The nginx_http.conf doesn't have an existing server listening on 80 as per what I see in the file

server {
    listen  127.4.xxx.xxx:8080;
    root    /var/lib/openshift/3456ce6589fc5f1fcc9999a3/app-root/runtime/repo//df/public;
    index index.php index.html index.htm;
    server_name server_domain_name_or_IP;

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

    # pass the PHP scripts to PHP-FPM
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/lib/openshift/3456ce6589fc5f1fcc9999a3/dreamfactory//socket/php-3456ce6589fc5f1fcc9999a3.socket;

        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        include /var/lib/openshift/3456ce6589fc5f1fcc9999a3/dreamfactory//usr/nginx-1.8.0/conf/fastcgi_params;
    }

}

Really appreciate any help. Thanks M.M