New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation incomplete #269

Closed
MyrionPhoenixmoon opened this Issue Aug 29, 2016 · 32 comments

Comments

Projects
None yet
3 participants
@MyrionPhoenixmoon

MyrionPhoenixmoon commented Aug 29, 2016

I just set up isso for my blog and ran into an issue with the documentation.

You mention embedding embed.min.js into the website, but you never once mention where it's from.

Since I already new about the Embed.js library I got the code from that library and called that up.

Lo and behold, nothing happened.

Luckily I found a blog (in french) which mentioned copying js files from isso/lib/python2.7/site-packages/isso/js into Apache's directories led me onto the straight path.

I therefore believe that it is necessary to include this into the documentation.
I can probably produce a Pull Request, if it would help, even though I haven't worked with Sphinx before.

@posativ

This comment has been minimized.

@posativ posativ closed this Aug 29, 2016

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

Yes, precisely there it is written that one should include embed.min.js into the page.
However, it is never mentioned where this embed.min.js comes from. My site/js/embed.min.js was not magically pointing at isso's site-packages!

Maybe I am missing something but where in the documentation is it written that insso-install-folder/lib/python2.7/site-packages/isso/js needs to be served up? I had to copy the contents of that folder into my /var/www/.

Or perhaps something went wrong when I used pip install and those files should have been in a much more obvious place. Even then, document where they are supposed to be and it would have been immediately obvious that something went wrong on my side.

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

There is no need to extract the JS and serve it manually. Isso does this, too. If you want to maintain a separate javascript file for Isso, go ahead. It will break with the next release.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

I faced the same situation and manually copied that to issopath/js/
Actually isso won't automatically async the embed.min.js for me either.
@posativ

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

What part of

<script data-isso="//comments.example.tld/"
        src="//comments.example.tld/js/embed.min.js"></script>

is unclear? data-isso is actually a prefix if the src for the JavaScript file. Manually serving the JavaScript is not supported by Isso.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

That's the code I use and certainly when curling the js url it'll show the code but if I don't manually copy embed.min.js to that path the js url will actually return a 404 error.
So I wonder if that could be done automatically?@posativ

1 similar comment
@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

That's the code I use and certainly when curling the js url it'll show the code but if I don't manually copy embed.min.js to that path the js url will actually return a 404 error.
So I wonder if that could be done automatically?@posativ

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

The 'embed.min.js' part. I didn't know that isso created or served such a file.

Plus, my isso runs on a non-public port. I wouldn't have guessed that I need to request localhost:1234/js/embed.min.js, since that's not served by my webserver or reachable from the client.

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

Whatever setup you use, if you proxy the Isso API, you also proxy the JavaScript and CSS.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

That's not my case it only proxy the isso.
The only js available is what I copied https://babybic.hu/isso/js/embed.min.js
Yep the isso url is https://babybic.hu/isso/
U could get a 404 error when u access https://babybic.hu/isso/js/count.min.js

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

So everything should be public after all? That contradicts another part of the documentation. And really it would just be much clearer if it said somewhere that isso also creates and serves that file or that this file must be publicly reachable...

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

@BabyBichu did you install Isso from GitHub?

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ I installed using pip3

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

Then your nginx configuration is incorrect. Isso will correctly serve the CORS header on e.g. https://babybic.hu/isso/js/foobar but if it ends with .js, your nginx configuration ignores Isso, check:

~> curl -Is https://babybic.hu/isso/js/asd.js
HTTP/1.1 404 Not Found
Server: nginx
Date: Tue, 30 Aug 2016 11:56:32 GMT
Content-Type: text/html
Content-Length: 3426
Connection: keep-alive
Vary: Accept-Encoding
ETag: "57b53862-d62"
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

~> curl -Is https://babybic.hu/isso/js/asd.lala
HTTP/1.1 404 NOT FOUND
Server: nginx
Date: Tue, 30 Aug 2016 11:56:36 GMT
Content-Type: text/html
Content-Length: 233
Connection: keep-alive
Access-Control-Allow-Origin: https://babybic.hu
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: HEAD, GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Origin, Referer, Content-Type
Access-Control-Expose-Headers: X-Set-Cookie, Date
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

@MyrionPhoenixmoon if I control the HTTP endpoint, then it doesn't matter. If you override certain endpoints for the prefix, e.g. /isso and images/css/js, it won't work. This is not Isso's fault. I can't control the HTTP proxy.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

location /isso {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Script-Name /isso;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:1234;
}

That's my configuration in the nginx file.
Wondering what's wrong with it

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

You have more in your nginx configuration than this. That is the issue.

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

I'll doublecheck my config tonight and see if I can get Apache to proxy /isso the way isso needs it. Either way, I feel that it needs to be written down in the documentation that isso serves up javascript files itself.

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

@MyrionPhoenixmoon send a PR. Web server configuration is not part of Isso though. The sample configuration in the documentation works, what you add to this configuration is no longer Isso's problem.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ maybe that's due to the line:
root /var/www/babybic.hu

So how to prevent the proxy from being influenced

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

@BabyBichu the curl request shows, that you have special handling for static files.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ ok will try deleting it and curl that one

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

Oh for sure. I'll see if I can make a PR with a sample Apache config and the two or three sentences about js that I feel are needed.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ I deleted the folder isso and curled but it still returns 404!

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

Why did you delete a folder? There is a directive in your nginx configuration, that adds special handling to assets, e.g. caching.

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ
Wondering what's wrong with the conf:

server {
listen 443 ssl http2;
ssl_certificate /usr/local/nginx/conf/ssl/babybic.hu.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/babybic.hu.key;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!DSS:!PKS;
ssl_session_cache builtin:1000 shared:SSL:10m;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
server_name babybic.hu www.babybic.hu;
access_log /data/wwwlogs/babybic.hu_nginx.log combined;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
index index.html index.htm index.php;
include /usr/local/nginx/conf/rewrite/none.conf;
root /data/wwwroot/babybic.hu;
if ($host != babybic.hu) {
rewrite ^/(.*)$ $scheme://babybic.hu/$1 permanent;
}
location /isso {
proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_header X-Script-Name /isso;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:1234;
}
error_page 403 404 500 502 503 504 /error.html;
location = /error.html {
            root /data/wwwroot/babybic.hu;
            internal;
    }
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;


# Discourage deep links by using a permanent redirect to home page of HTTPS site
#return 301 https://$host;

# Alternatively, redirect all HTTP links to the matching HTTPS page
return 301 https://$host$request_uri;
}
@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

There is a directive in your nginx configuration, that adds special handling to assets, e.g. caching.

location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ Thanks! It now works like charm! Just deleted the |js

@MyrionPhoenixmoon

This comment has been minimized.

MyrionPhoenixmoon commented Aug 30, 2016

Okay, so in my case there were two issues:

1 I didn't need data-isso at all and
2 Always specify paths to proxy with a trailing slash.

I'll get to work on a PR the day after tomorrow, most likely.

@posativ

This comment has been minimized.

Owner

posativ commented Aug 30, 2016

@BabyBichu good to hear! I wonder why Nginx uses the regex location instead of a simple prefix, but I can't really make a order from this statement here (except: the longer the better). http://nginx.org/en/docs/http/ngx_http_core_module.html#location

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Aug 30, 2016

@posativ I will optimize it in my leasure time. Anyway thanks for ur timely and detailed help!

@SnorlaxYum

This comment has been minimized.

SnorlaxYum commented Sep 18, 2016

@posativ I see, the “/documents/document.html” request will match configuration C.
So If I use

location /documents/ {
    expires 30d;
    access_log off;
    }

It'll cache all the files under /documents/ for 30 days. Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment