Drukowana wersja tematu

Kliknij tu, aby zobaczyć temat w orginalnym formacie

Forum PHP.pl _ Serwery WWW _ DirectAdmin i włączony SSL dla domeny - TOO_MANY_REDIRECTS

Napisany przez: adikdvb 9.05.2018, 10:48:09

Witajcie,

Zmagam się od wczoraj z następującym problemem. Korzystam z DirectAdmin'a na jednym z VPS, na innych jest czysty Debian, zdecydowanie bardziej preferuję nginx'a.

Certyfikaty wildcard SSL zakupione, DA prawidłowo je rozpoznał i pokazał datę ważności. Po włączeniu obsługi SSL dla jednej z domen, na którym stoi sklep internetowy mam błąd ERR_TOO_MANY_REDIRECTS.

Umieściłem w pliku .htaccess zalecane przez help DA przekierowania:

  1. RewriteEngine On
  2. RewriteCond %{HTTPS} off
  3. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Konfigurację vhostów wrzuciłem tutaj: https://pastebin.com/Jv9EZa3X

Sklep został zainstalowany w katalogu /public_html/application/public i tam też jest plik .htaccess, który wygląda następująco:

  1. #AddHandler x-httpd-php53 .php
  2.  
  3. RewriteEngine On
  4. RewriteCond %{HTTPS} off
  5. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  6.  
  7. # use if needed:
  8. #RewriteBase /
  9.  
  10. RewriteRule ^$ / [QSA]
  11.  
  12. RewriteCond %{REQUEST_FILENAME} ([a-z_]+?)_picture/(.*?)\.(?:jpg|png)$
  13. RewriteCond %{REQUEST_FILENAME} !-f
  14. RewriteRule ([a-z_]+?)_picture/(.*?)/(.*?)\.(jpg|png)$ thumbnailer/create/$1/$2/$3/$4 [QSA,L]
  15.  
  16. # some hosts need redirect:
  17. # RewriteRule ([a-z_]+?)_picture/(.*?)/(.*?)\.(jpg|png)$ thumbnailer/create/$1/$2/$3/$4 [QSA,R,L]
  18.  
  19. # redirects request to nonexisting CSS and JS to empty CSS/JS files [so you dont need to define module CSS/JS if you dont need it]
  20. RewriteCond %{REQUEST_FILENAME} ^(.*?)\.css$
  21. RewriteCond %{REQUEST_FILENAME} !-f
  22. RewriteRule ^(.*)$ stylesheets/core/no_css.css [QSA,L]
  23.  
  24. RewriteCond %{REQUEST_FILENAME} ^(.*?)\.js$
  25. RewriteCond %{REQUEST_FILENAME} !-f
  26. RewriteRule ^(.*)$ javascript/core/no_js.js [QSA,L]
  27.  
  28.  
  29. # displays 404.html if IMAGE is not found
  30. RewriteCond %{REQUEST_FILENAME} !-f
  31. RewriteCond %{REQUEST_URI} images/.*?(png|jpg|gif)
  32. # ^^ may catch valid requests that contain "images/" and have image extension!!!!
  33. RewriteRule ^(.*)$ 404.html [QSA,L]
  34.  
  35. RewriteCond %{REQUEST_FILENAME} !-f
  36. RewriteRule ^(.*)$ index.php/$1 [QSA,L]
  37. # also OK RewriteRule ^(.*)$ index.php/%{REQUEST_FILENAME} [QSA,L]
  38.  
  39.  
  40. # define error pages
  41. ErrorDocument 404 error_page.php
  42. ErrorDocument 406 error_page.php
  43. ErrorDocument 500 error_page.php


Dzisiaj spróbowałem jeszcze jednej rzeczy. Przeniosłem wszystkie pliki sklepu wraz z katalogami z public_html do private_html. Zmieniłem w DA

  1. |*if !SUB|
  2. |?DOCROOT=/home/admin/domains/my-shop.net/public_html/application/public|
  3. |*endif|


na

  1. |*if !SUB|
  2. |?DOCROOT=/home/admin/domains/my-shop.net/private_html/application/public|
  3. |*endif|


W lokalizacji /public_html/application/public stworzyłem .htaccess z zawartością:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Po odświeżeniu domeny sklepu pojawiła się zielona kłódka, niestety są błędy:

  1. Warning: require_once(/home/admin/domains/my-shop.net/public_html/application/public/../../framework/gp/event_dispatcher/EventDispatcherGP.php): failed to open stream: No such http://www.php.net/file or directory in /home/admin/domains/my-shop.net/private_html/framework/autoloader/Autoloader.php on line 66
  2.  
  3. Fatal error: require_once(): Failed opening required '/home/admin/domains/my-shop.net/public_html/application/public/../../framework/gp/event_dispatcher/EventDispatcherGP.php' (include_path='.:/usr/local/lib/php:/home/admin/domains/my-shop.net/private_html/application:/home/admin/domains/my-shop.net/private_html/framework:/home/admin/domains/my-shop.net/private_html/framework/libs/:/home/admin/domains/my-shop.net/private_html/application/libs/ThirdParty') in /home/admin/domains/my-shop.net/private_html/framework/autoloader/Autoloader.php on line 66


Zrobiłem też link symboliczny, ale nie pomogło:

ln -s /private_html/application/public -> /public_html/application/public

Sprawdziłem wszystkie pliki w katalogu config i nie mogę znaleźć dlaczego skrypt chce wczytywać z public_html. Macie jakieś pomysły a może źle kombinuję? Przypuszczam, że gdzieś trzeba odświeżyć wpisy, w bazie danych nic nie widzę. Sklep www jest na silniku i-sklep.pl (i-systems.pl). Gdyby to była Presta lub coraz bardziej popularny thirtybees to sprawa jest prosta.

Dodam jeszcze, że subdomena z zainstalowaną Livezillą do obsługi chatu działa po https prawidłowo.

PS. Znalazłem plik ssl_template.php, ale to chyba nie to...

  1. <?php
  2. /**
  3.  * 1. Enable SSL in 'enabled'
  4.  * 2. Define which domains (not aliases) should use SSL in 'ssl_domains'
  5.  * 3. Configure 'admin_sections_prefixes' if needed (this is to support '/admin/*' urls)
  6.  * 4. Configure controllers to return public function getActionsForSSL()
  7.  * 5. Refresh controller configuration cache in /admin/technical_panel
  8.  * 5.1 Refresh this cache config after each change in controllers
  9.  */
  10. return http://www.php.net/array(
  11. 'enabled' => true,
  12. // 'enabled' => false,
  13.  
  14. 'ssl_domains' => http://www.php.net/array(
  15. 'secure.site.pl'
  16. ),
  17.  
  18. // check plugins.php
  19. // and copy all prefixes configured in: $pluginManager->registerPlugin( Framework_Plugins_PluginManager::AFTER_ROUTING, new Application_AdminSectionPlugin(array('admin')));
  20. 'admin_sections_prefixes' => http://www.php.net/array(
  21. 'admin',
  22. )
  23. );

Napisany przez: Pyton_000 9.05.2018, 12:10:00

Pokaż Autoloader.php, nie ma tam gdzieś żadnego pliku config albo coś?

Napisany przez: adikdvb 9.05.2018, 12:19:57

W katalogu application/public jest plik autoload.php:

  1. <?php
  2. include (__DIR__.'/../../framework/core/Client.php');
  3. include (__DIR__.'/../../application/modules/shop_core/Resources/TrustedHostsInterface.php');
  4. include (__DIR__.'/../../application/modules/shop_core/Resources/iSystemsTrustedHost.php');
  5.  
  6. $trustedHosts = new iSystemsTrustedHost('http://panel.i-sklep.pl/secure_host');
  7. $clientHost = Framework_Core_Client::getHost($overProxy = true);
  8.  
  9. if(!$trustedHosts->isHostTrusted($clientHost))
  10. {
  11. http://www.php.net/header('HTTP/1.0 403 Forbidden');
  12. http://www.php.net/exit();
  13. }
  14.  
  15. http://www.php.net/echo '<pre>';
  16.  
  17. http://www.php.net/error_reporting(E_ALL);
  18. http://www.php.net/ini_set( 'memory_limit', '128M' );
  19. require_once('app_config.php');
  20. require_once( $appDir . '/config/framework_env.php' );
  21. // DONT INCLUDE require_once( $appDir . '/config/environment.php' );
  22. require_once( http://www.php.net/dirname(http://www.php.net/dirname( __FILE__ )) . '/config/theme.php' );
  23. $application_base_dir = http://www.php.net/join( DIRECTORY_SEPARATOR, http://www.php.net/array( http://www.php.net/dirname(http://www.php.net/dirname( __FILE__ ))) );
  24. $framework_classes_base_dir = http://www.php.net/join( DIRECTORY_SEPARATOR, http://www.php.net/array( http://www.php.net/dirname( __FILE__ ),'..', '..', 'framework' ) );
  25. //---
  26.  
  27. doAutoload($framework_classes_base_dir, $application_base_dir);
  28. clearCompiledTemplates($application_base_dir);
  29.  
  30. /*
  31. to jest chyba jednak zbedne...
  32.  
  33. clearMinifiedJS($application_base_dir);
  34. clearMinifiedCSS($application_base_dir);
  35. */
  36.  
  37. createSymlinksTo($application_base_dir, '*.css', 'stylesheets');
  38. createSymlinksTo($application_base_dir, '*.js', 'javascript');
  39. createCustomizedSymlinksTo($application_base_dir, '*.css', 'stylesheets');
  40. createCustomizedSymlinksTo($application_base_dir, '*.js', 'javascript');
  41.  
  42. http://www.php.net/echo '</pre>';
  43.  
  44. function doAutoload($framework_classes_base_dir, $application_base_dir)
  45. {
  46. $autoloaderBaseDir = $framework_classes_base_dir . '/autoloader/';
  47. require_once( $autoloaderBaseDir . 'ClassMap.php' );
  48. require_once( $autoloaderBaseDir . 'ClassMapGenerator.php' );
  49. require_once( $autoloaderBaseDir . 'PREGClassMapGenerator.php');
  50. require_once( $autoloaderBaseDir . 'ClassSpider.php' );
  51.  
  52. http://www.php.net/set_include_path( http://www.php.net/get_include_path() . PATH_SEPARATOR . $application_base_dir . PATH_SEPARATOR . $framework_classes_base_dir );
  53.  
  54. $classMap = new Framework_Autoloader_ClassMap();
  55. $classMapGenerator = new Framework_Autoloader_PREGClassMapGenerator($classMap);
  56.  
  57. $appSpider = new Framework_Autoloader_ClassSpider( $application_base_dir, false );
  58. $appSpider->skipPath('.bzr');
  59. $appSpider->skipPath('.git');
  60. $appSpider->skipPath('application/tmp');
  61. $appSpider->skipPath('application/logs');
  62. $appSpider->skipPath('application/public');
  63. $appSpider->skipPath('application/config');
  64. $appSpider->skipPath('application/modules/[a-zA-Z0-9_]+/(?:tpl|tpl_admin|lang|install[^install_handlers])');
  65.  
  66. $classMapGenerator->addClassesFrom( $appSpider );
  67.  
  68. $fwSpider = new Framework_Autoloader_ClassSpider( $framework_classes_base_dir, false );
  69. $fwSpider->skipPath('.bzr');
  70. $fwSpider->skipPath('.git');
  71. $classMapGenerator->addClassesFrom( $fwSpider );
  72.  
  73. $classMap->saveTo( $application_base_dir . '/tmp/var/class_map.php' );
  74. http://www.php.net/print( "Classes found: " . $classMap->countClasses() . "\n");
  75. http://www.php.net/printf( "Memory usage: %.2f MiB\n", memory_get_peak_usage() / 1024 / 1024 );
  76. }
  77.  
  78.  
  79. function clearCompiledTemplates($application_base_dir)
  80. {
  81. // clear templates
  82. foreach ( http://www.php.net/glob($application_base_dir . "/tmp/compiled_templates/*.php") as $file )
  83. {
  84. http://www.php.net/unlink($file);
  85. }
  86.  
  87. foreach ( http://www.php.net/glob($application_base_dir . "/tmp/dynamic_templates/*.php") as $file )
  88. {
  89. http://www.php.net/unlink($file);
  90. }
  91. }
  92.  
  93. function clearMinifiedJS($application_base_dir)
  94. {
  95. foreach ( http://www.php.net/glob($application_base_dir . "/public/javascript/min/*.js") as $file )
  96. {
  97. http://www.php.net/unlink($file);
  98. }
  99. }
  100.  
  101. function clearMinifiedCSS($application_base_dir)
  102. {
  103. foreach ( http://www.php.net/glob($application_base_dir . "/public/stylesheets/min/*.css") as $file )
  104. {
  105. http://www.php.net/unlink($file);
  106. }
  107. }
  108.  
  109. function createSymlinksTo($application_base_dir, $extension, $dir)
  110. {
  111. foreach ( http://www.php.net/glob( $application_base_dir . '/modules/**/' . $extension) as $filepath )
  112. {
  113. $pathElements = http://www.php.net/explode('/', $filepath);
  114.  
  115. $filename = http://www.php.net/array_pop($pathElements);
  116. $moduleName = http://www.php.net/array_pop($pathElements);
  117.  
  118. if ( ($moduleName == "_template") || ($moduleName == "_base") )
  119. {
  120. continue;
  121. }
  122.  
  123. $symlink = $application_base_dir . '/public/' . $dir . '/modules/' . $filename;
  124. $target = $application_base_dir . "/modules/" . $moduleName . '/' . $filename;
  125. $realFilepath = $filepath;
  126.  
  127. doCreateSymlink($symlink, $target, $filename, $realFilepath);
  128. }
  129.  
  130.  
  131. // /some/dir/application/ -> /some/dir/customized/THEME/
  132. // this replaces files found in regular modules with these customized ones
  133. $customizedBaseDir = http://www.php.net/preg_replace( '#application$#', 'customized/' . APPLICATION_THEME_DIR, $application_base_dir);
  134.  
  135. foreach ( http://www.php.net/glob( $customizedBaseDir . '/modules/**/' . $extension ) as $filepath )
  136. {
  137. $pathElements = http://www.php.net/explode('/', $filepath);
  138.  
  139. $filename = http://www.php.net/array_pop($pathElements);
  140. $moduleName = http://www.php.net/array_pop($pathElements);
  141.  
  142. if ( ($moduleName == "_template") || ($moduleName == "_base") )
  143. {
  144. continue;
  145. }
  146.  
  147. $symlink = $application_base_dir . '/public/' . $dir . '/modules/' . $filename;
  148. $target = $application_base_dir . "/../customized/" . APPLICATION_THEME_DIR . "/modules/" . $moduleName . '/' . $filename;
  149. $realFilepath = $filepath;
  150.  
  151. doCreateSymlink($symlink, $target, $filename, $realFilepath);
  152. }
  153. }
  154.  
  155. /**
  156.  * Only for /customized/DOMAIN_NAME
  157.  * Where DOMAIN_NAME must have a dot, so 'default' will be excluded
  158.  *
  159.  * @param unknown_type $application_base_dir
  160.  * @param unknown_type $extension
  161.  * @param unknown_type $dir
  162.  */
  163. function createCustomizedSymlinksTo( $application_base_dir, $extension, $dir)
  164. {
  165. // /some/dir/application/ -> /some/dir/customized/THEME/
  166. $customizedBaseDir = http://www.php.net/preg_replace( '#application$#', 'customized', $application_base_dir);
  167.  
  168. $patt = $customizedBaseDir . '/*/';
  169. foreach ( http://www.php.net/glob( $patt) as $themeDirPath )
  170. {
  171. $themeName = http://www.php.net/basename($themeDirPath);
  172. if ( http://www.php.net/is_dir($themeDirPath) ) // check for dot in name (domain name!!)
  173. {
  174. http://www.php.net/print( "Processing customized theme: " . $themeName . "<br />");
  175.  
  176. // files from modules (modules/MODULE/FILE.css|js)
  177. foreach ( http://www.php.net/glob( $themeDirPath . 'modules/**/' . $extension) as $filepath )
  178. {
  179. $pathElements = http://www.php.net/explode('/', $filepath);
  180.  
  181. $filename = http://www.php.net/array_pop($pathElements);
  182. $moduleName = http://www.php.net/array_pop($pathElements);
  183.  
  184. if ( ($moduleName == "_template") || ($moduleName == "_base") )
  185. {
  186. continue;
  187. }
  188.  
  189. http://www.php.net/print( "Customized: " . $filepath ."\n");
  190. // application/public/[stylesheets/javascript]/templateName/MODULE.css etc.
  191. $symlink = $application_base_dir . '/public/' . $dir . '/' . $themeName . '/modules/' . $filename;
  192. $target = $customizedBaseDir . "/" . $themeName . "/modules/" . $moduleName . '/' . $filename;
  193.  
  194. $realFilepath = $filepath;
  195.  
  196. doCreateSymlink($symlink, $target, $filename, $realFilepath);
  197. }
  198.  
  199. // global files (not within modules)
  200. foreach ( http://www.php.net/glob( $themeDirPath . '*' . $extension) as $filepath )
  201. {
  202. $pathElements = http://www.php.net/explode('/', $filepath);
  203.  
  204. $filename = http://www.php.net/array_pop($pathElements);
  205. $moduleName = http://www.php.net/array_pop($pathElements);
  206.  
  207. if ( ($moduleName == "_template") || ($moduleName == "_base") )
  208. {
  209. continue;
  210. }
  211.  
  212. http://www.php.net/print( "Customized not module: " . $filepath ."\n");
  213. // application/public/DOMAIN.NAME/stylesheets/modules/MODULE.css etc.
  214. $symlink = $application_base_dir . '/public/' . $dir . '/' . $themeName . '/' . $filename;
  215. $target = $customizedBaseDir . "/" . $themeName . "/" . $filename;
  216.  
  217. $realFilepath = $filepath;
  218.  
  219. doCreateSymlink($symlink, $target, $filename, $realFilepath);
  220. }
  221.  
  222. }
  223. }
  224.  
  225.  
  226. }
  227.  
  228. function doCreateSymlink( $symlink, $target, $filename, $realFilepath)
  229. {
  230. // fix for symlinks to non-existing files
  231. `rm -f $symlink`;
  232.  
  233. // strip absolute path for security reasons
  234. $relativelFilePath = http://www.php.net/substr($realFilepath, http://www.php.net/strpos($realFilepath, 'application/'));
  235.  
  236. http://www.php.net/print( "Creating... " . $filename . " from " . $relativelFilePath . " <br/>");
  237. crossOsSymlink( $target, $symlink );
  238. }
  239.  
  240.  
  241. function crossOsSymlink($target, $symlink)
  242. {
  243. $symlinkDir = http://www.php.net/dirname($symlink);
  244. if ( ! http://www.php.net/file_exists($symlinkDir))
  245. {
  246. http://www.php.net/mkdir( $symlinkDir, 0755, true);
  247. }
  248. if(http://www.php.net/strtoupper(http://www.php.net/substr(PHP_OS, 0, 3))==='WIN')
  249. {
  250. return http://www.php.net/copy( $target, $symlink );
  251. }
  252.  
  253. return symlink( $target, $symlink );
  254. }


Wrzucam też plik app_config.php, może tutaj trzeba zmienić?

  1. <?php
  2. // PATH to applicaiton base dir!
  3. $appDir = http://www.php.net/dirname( __FILE__ ) . '/../';
  4. ?>

Napisany przez: LowiczakPL 9.05.2018, 22:41:03

odśwież autoloader

  1. composer dump-autoload

Napisany przez: adikdvb 10.05.2018, 20:28:08

Wreszcie działa, brakowało pliku ssl.php z nazwami dozwolonych domen oraz ssl_actions_cache.php z nazwami klas, gdzie ma być włączony SSL.

snitch.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)