Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> DirectAdmin i włączony SSL dla domeny - TOO_MANY_REDIRECTS, pętla przekierowań po https
adikdvb
post 9.05.2018, 10:48:09
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 27.07.2009

Ostrzeżenie: (0%)
-----


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 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 array(
  11. 'enabled' => true,
  12. // 'enabled' => false,
  13.  
  14. 'ssl_domains' => 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' => array(
  21. 'admin',
  22. )
  23. );


Ten post edytował adikdvb 9.05.2018, 10:58:48
Go to the top of the page
+Quote Post
Pyton_000
post 9.05.2018, 12:10:00
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Pokaż Autoloader.php, nie ma tam gdzieś żadnego pliku config albo coś?
Go to the top of the page
+Quote Post
adikdvb
post 9.05.2018, 12:19:57
Post #3





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 27.07.2009

Ostrzeżenie: (0%)
-----


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


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

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


Ten post edytował adikdvb 9.05.2018, 12:25:28
Go to the top of the page
+Quote Post
LowiczakPL
post 9.05.2018, 22:41:03
Post #4





Grupa: Zarejestrowani
Postów: 531
Pomógł: 55
Dołączył: 3.01.2016
Skąd: Łowicz

Ostrzeżenie: (0%)
-----


odśwież autoloader

  1. composer dump-autoload


--------------------
Szukam zleceń Symfony, Laravel, Back-End, Front-End, PHP, MySQL ...
Go to the top of the page
+Quote Post
adikdvb
post 10.05.2018, 20:28:08
Post #5





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 27.07.2009

Ostrzeżenie: (0%)
-----


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

Ten post edytował adikdvb 11.05.2018, 09:24:58
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 09:48