Announcement

#1 2016-10-09 13:32:05

kyp_
Member
2013-06-17
84

Switch to HTTPS keeps an absolute path for /combined/

Hello,


NGINX
Piwigo version: 2.7.4
PHP: 5.4.45
MySQL: 5.5.46


When I tried to switch to HTTPS, half the site worked, but parts (css,js) had an absolute path
which pointed always to HTTP.

I've tried the plugin "Force HTTPS", but it caused an "endless redirect" when activated
with a "499" http error.


Here is the odd part:
on /index.php?/
<script type="text/javascript" src="http://domain.com/_data/combined/.."></script>

on /picture.php?/
<script type="text/javascript" src="_data/combined/.."></script>

edit: it was "_data/..." and not "/_data/..."


Why is the combined-path-output "absolute" on index.php?, and how can I change it to a
relative path, so it will work for HTTPS?

I'd be grateful for ANY kind of directions :)



regards,
Kyp

-----------------------------
Plugins:
    Add < head > element
    Admin Tools
    Autocomplete
    Colored Tags
    Community
    Crypto Captcha
    Embedded Videos
    Extended Description
    GThumb+
    LocalFiles Editor
    Manage meta tags
    Media Icon
    Prune History
    Sitemap
    SmartAlbums
    Social Buttons
    User Collections
    User Tags
    VideoJS

Last edited by kyp_ (2016-10-10 11:45:55)


Cheers

Offline

 

#2 2016-10-09 20:14:14

erAck
Piwigo Team
2015-09-06
304

Re: Switch to HTTPS keeps an absolute path for /combined/

kyp_ wrote:

on /index.php?/
<script type="text/javascript" src="http://domain.com/_data/combined/.."></script>

on /picture.php?/
<script type="text/javascript" src="/_data/combined/.."></script>

Why is the combined-path-output "absolute" on index.php?, and how can I change it to a
relative path, so it will work for HTTPS?

Note that src="/_data/combined/..." isn't relative either, it just lacks the protocol and host parts. Relative would be src="_data/combined/..." without leading '/' slash, which btw it is for me in both outputs, also in https, but that's in 2.8.2.

You could debug/track include/template.class.php make_script_src() if it is called with a script for which is_remote() evaluates to true, which would explain why the root part is not stripped, and then trace back from where that originates.


Running Piwigo at https://erack.net/gallery/

Online

 

#3 2016-10-10 00:41:42

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

Thanks for the suggestion, but:
Piwigo 2.7.4 should be pretty straight forward in setting up HTTPS, without any dabbling in php code?


Cheers

Offline

 

#4 2016-10-10 22:43:26

Zentalquabula
Member
2014-05-10
99

Re: Switch to HTTPS keeps an absolute path for /combined/

You could always update to 2.8.2, although I am sure Piwigo has been ready out of the box for HTTPS since long. Works for me.

Offline

 

#5 2016-10-12 13:22:05

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

All core files are default, nothing was changed.
The only difference is NGINX really, and no rewrite rules are
used, or it would rewrite both /index.php?/ and /picture.php?/

/index.php? ->   src="http://domain.com/_data

/picture.php? -> src="_data/

Any idea how I could replicate the working "picture.php?" path on the
not-working "index.php?" path?


Cheers

Offline

 

#6 2016-10-12 15:30:15

teekay
Member
2013-06-12
427

Re: Switch to HTTPS keeps an absolute path for /combined/

Try to delete compiled templates in Administration -> Tools -> Maintenance.

Offline

 

#7 2016-10-16 15:07:25

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

Deleted all templates via Maintenance - still the same HTTP Paths



Code:

<head>
<meta charset="utf-8">
...

<!-- BEGIN get_combined -->
<link rel="stylesheet" type="text/css" href="http://mydomain.com/_data/combined/sz.....css">
<script type="text/javascript" src="http://mydomain.com/themes/default/js/jquery.min.js?v2.7.4"></script>
<!-- END get_combined -->



...



<!-- Footer -->
<!-- BEGIN get_combined -->
<script type="text/javascript" src="http://mydomain.com/_data/combined/1u.....js"></script>
<script type="text/javascript">//<![CDATA[

var RVAC={root:"plugins/rv_autocomplete/"};
$("#qsearchInput").one("focus", function() {
var s;
s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="_data/combined/acds-....js";document.body.appendChild(s);
s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="plugins/rv_autocomplete/res/suggest-core.js";document.body.appendChild(s);
s="plugins/rv_autocomplete/res/dark-hive/custom.css";
if (document.createStyleSheet) document.createStyleSheet(s); else $("head").append($("<link rel='stylesheet' href='"+s+"' type='text/css'>"));
});
var RVTS = {
ajaxUrlModel: String.fromCharCode(105)+'ndex.php?/tags/TAG1/start-%start%&rvts=%per%',
start: 0,
perPage: 30,
next: 30,
total: 4062,
urlModel: String.fromCharCode(105)+'ndex.php?/tags/TAG1/start-%start%',
moreMsg: 'Next <br>(%d more photos)',
prevMsg: 'Previous',
ajaxLoaderImage: 'plugins/rv_tscroller/ajax-loader.gif'
};
jQuery('.navigationBar').hide();
GThumb.max_height = 230;
GThumb.margin = 10;
GThumb.method = 'resize';


GThumb.build();
jQuery(window).bind('RVTS_loaded', GThumb.build);
jQuery('#thumbnails').resize(GThumb.process);
var p_main_menu = "", p_pict_descr = "", p_pict_comment = "";
(SwitchBox=window.SwitchBox||[]).push("#sortOrderLink", "#sortOrderBox");
//]]></script>
<script type="text/javascript">
(function() {
var s,after = document.getElementsByTagName('script')[document.getElementsByTagName('script').length-1];
s=document.createElement('script'); s.type='text/javascript'; s.async=true; s.src='http://mydomain.com/_data/combined/4....js';
after = after.parentNode.insertBefore(s, after);
})();
</script>
<!-- END get_combined -->

</body>

Cheers

Offline

 

#8 2016-10-17 12:38:25

flop25
Piwigo Team
2006-07-06
6965

Re: Switch to HTTPS keeps an absolute path for /combined/

we never had any issue with https
for me on any pages I always have <script type="text/javascript" src="_data/combined/****.js"></script>

what's your theme? have tried changing it?

and what's in your local config?


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#9 2016-10-17 13:11:30

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

I'm using the "elegant theme", and a modified elegant-theme for mobile.


local/config/config.inc.php>

Code:

<?php
$conf['show_gt'] = false;
/* The file does not exist until some information is entered 
below. Once information is entered and saved, the file will be created. */

// show_queries : for debug purpose, show queries and execution times
$conf['show_queries'] = false;

/* theme-switcher-plugin */
$conf['theme_switch_mode']='select';

// the author shown in the RSS feed <author> element
$conf['rss_feed_author'] = 'mydomain.com';

// Parameters used in get_recent_post_dates for the 2 kind of notification
$conf['recent_post_dates'] = array(
  'RSS' => array('max_dates' => 8, 'max_elements' => 12, 'max_cats' => 6),
  'NBM' => array('max_dates' => 7, 'max_elements' => 3, 'max_cats' => 9)
  );


$conf['show_exif'] = false;

$conf['use_exif'] = false;


$conf['question_mark_in_urls'] = true;


$conf['random_index_redirect'] = array('index.php?/category/most-popular' => '');


$lang['Menu'] = "Menu (Show/Hide)";

// top_number : number of element to display for "best rated" and "most
// visited" categories
$conf['top_number'] = 100;

$conf['derivative_default_size'] = 'xxlarge';

// tag_url_style : one of 'id-tag' (default), 'id' or 'tag'.
// Note that if you choose 'tag' and the url (ascii) representation of your
// tags is not unique, all tags with the same url representation will be shown
$conf['tag_url_style'] = 'tag';



// +-----------------------------------------------------------------------+
// | Slideshow                                                             |
// +-----------------------------------------------------------------------+
// slideshow_period : waiting time in seconds before loading a new page
// during automated slideshow
// slideshow_period_min, slideshow_period_max are bounds of slideshow_period
// slideshow_period_step is the step of navigation between min and max
$conf['slideshow_period_min'] = 1;
$conf['slideshow_period_max'] = 40;
$conf['slideshow_period_step'] = 1;
$conf['slideshow_period'] = 5;



// +-----------------------------------------------------------------------+
// |                                 tags                                  |
// +-----------------------------------------------------------------------+

// full_tag_cloud_items_number: number of tags to show in the full tag
// cloud. Only the most represented tags will be shown
$conf['full_tag_cloud_items_number'] = 1000;

// menubar_tag_cloud_items_number: number of tags to show in the tag
// cloud in the menubar. Only the most represented tags will be shown
$conf['menubar_tag_cloud_items_number'] = 35;

// content_tag_cloud_items_number: number of related tags to show in the tag
// cloud on the content page, when the current section is not a set of
// tags. Only the most represented tags will be shown
$conf['content_tag_cloud_items_number'] = 35;

// tags_levels: number of levels to use for display. Each level is bind to a
// CSS class tagLevelX.
$conf['tags_levels'] = 5;

// tags_default_display_mode: group tags by letter or display a tag cloud by
// default? 'letters' or 'cloud'.
$conf['tags_default_display_mode'] = 'cloud';

// tag_letters_column_number: how many columns to display tags by letter
$conf['tag_letters_column_number'] = 2;

?>

If you need any specific .tpl code posted, please let me know.


Cheers

Offline

 

#10 2016-10-17 13:56:29

flop25
Piwigo Team
2006-07-06
6965

Re: Switch to HTTPS keeps an absolute path for /combined/

that's indeed induced by nginx (i can't reproduce and no one reported yet) and maybe due to the path construction of Piwigo but that's way above my knowledge. I notify Rvelices who might help you


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#11 2016-10-17 14:03:11

rvelices
Piwigo Team
2005-12-29
1960

Re: Switch to HTTPS keeps an absolute path for /combined/

kyp,

If you look at the RSS feed (feed.php) OR you use piwigo to send mails, does the domain appear correctly with https ?

I suspect it does not, in which case I suggest taking a look to function get_absolute_root_url (in include/functions_url.inc.php) and tell us what $_SERVER variables look like ...

Offline

 

#12 2016-10-17 16:16:28

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

The feed links are all shown as HTTP.


include/functions_url.inc.php - line 48:

Code:

function get_absolute_root_url($with_scheme=true)
{
  // TODO - add HERE the possibility to call PWG functions from external scripts
  $url = '';
  if ($with_scheme)
  {
    $is_https = false;
    if (isset($_SERVER['HTTPS']) &&
      ((strtolower($_SERVER['HTTPS']) == 'on') or ($_SERVER['HTTPS'] == 1)))
    {
      $is_https = true;
      $url .= 'https://';
    }
    else
    {
      $url .= 'http://';
    }
    $url .= $_SERVER['HTTP_HOST'];
    if ( (!$is_https && $_SERVER['SERVER_PORT'] != 80)
          ||($is_https && $_SERVER['SERVER_PORT'] != 443))
    {
      $url_port = ':'.$_SERVER['SERVER_PORT'];
      if (strrchr($url, ':') != $url_port)
      {
        $url .= $url_port;
      }
    }
  }
  $url .= cookie_path();
  return $url;
}

Cheers

Offline

 

#13 2016-10-17 16:40:25

flop25
Piwigo Team
2006-07-06
6965

Re: Switch to HTTPS keeps an absolute path for /combined/

kyp_ wrote:

The feed links are all shown as HTTP.


include/functions_url.inc.php - line 48:

yes but insert an print_r, var_dump or var_export as you like to get the value of  $_SERVER as requested by rvelices


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#14 2016-10-17 22:09:15

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

Yeah, I kind of expected something like that - since I dont know any php.

What I've tried:
footer.tpl:
{var_dump($_SERVER)}

Output via HTTPS index.php: NULL
Output via HTTPS picture.php: null


If this is not it, please tell me, where specifically, to add the var_dump :)


Cheers

Offline

 

#15 2016-10-21 02:19:09

kyp_
Member
2013-06-17
84

Re: Switch to HTTPS keeps an absolute path for /combined/

Is there any more info that I can provide?


Cheers

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact