Skip to content
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

Question #20

Closed
seve26 opened this issue Oct 9, 2021 · 14 comments
Closed

Question #20

seve26 opened this issue Oct 9, 2021 · 14 comments

Comments

@seve26
Copy link

seve26 commented Oct 9, 2021

Hello after installing Cinemapress, the site url is set like this: all non www and www are redirected to https://example.com.

I would love to know how to redirect all non-www and www to https and www using Nginx. I'm familiar with apache and htaccess but I'm newbie with ngnix... How to do something like this?

example.com -> https://www.example.com
http://example.com -> https://www.example.com
http://www.example.com -> https://www.example.com
www.example.com  -> https://www.example.com
https://example.com > https://www.example.com

Thanks a lot
Best Regard

@zeldaroot
Copy link
Contributor

Hello.

image

  1. HTTPS - main protocol (by CloudFlare or by cinemapress https)
  2. www - sub-domain
  3. Email and Global Key CloudFlare - https://dash.cloudflare.com/profile/api-tokens
  4. Proxied - for HTTPS by CloudFlare, if you have your own certificate (by cinemapress https), then you don't have Proxied

Fill in the CloudFlare data first and only then add a subdomain. It will be registered in DNS automatically.

@seve26
Copy link
Author

seve26 commented Oct 10, 2021

Hello,
Thanks a lot for your reply. HTTPS was already activated in my site so I setuped the API CloudFlare with email and api key then I added www in Domain for users but when I clic on Save Changes I get this error:

subdomain

NOT «m.», «tv.», «www.», «app.», «ftp.»!

  1. Apparently www subdomain are not allowed. What should I do?

  2. Regarding SSL, I own a certificat but I don't know where to upload the ssl certificate (ssl-bundle.crt) and the ssl certificate key (domain.key) and what should I modify in the Ngnix configuration file and where to locate this file?

Thanks again!
Best Regards

@zeldaroot
Copy link
Contributor

zeldaroot commented Oct 10, 2021

Oops, I'm sorry. I forgot to push.

  1. In fact, I looked at the code, and I think there is no point in this restriction, it can be ignored.
  2. If you have your own certificate, then do this:
    • First generate wildcard certificate cinemapress https
    • Now replace the generated certificates from the folders with your certificate files.

/config/production/nginx/ssl.d/default.conf

ssl_certificate /home/example.com/config/production/nginx/ssl.d/live/example.com/fullchain.pem;
ssl_certificate_key /home/example.com/config/production/nginx/ssl.d/live/example.com/privkey.pem;
ssl_dhparam /home/example.com/config/production/nginx/ssl.d/live/example.com/dhparam.pem;

I think you should not replace the certificates with others, since Let's Encrypt provides these wildcard certificates for free and with automatic renewal.

@seve26
Copy link
Author

seve26 commented Oct 10, 2021

Hello,
Thank's a lot for your reply. Now I'm able to save the change after adding www but when I go to www.example.com I have an error:

too-many-redirect

This page is not working
www.example.com has redirected you too many times.
Try to delete cookies.
ERR_TOO_MANY_REDIRECTS

Best Regards

EDIT: when I delete www from Domain for users the site is showing as before.

@zeldaroot
Copy link
Contributor

zeldaroot commented Oct 11, 2021

̶T̶h̶e̶ ̶ www ̶s̶u̶b̶d̶o̶m̶a̶i̶n̶ ̶i̶s̶ ̶a̶ ̶v̶e̶s̶t̶i̶g̶e̶ ̶o̶n̶ ̶t̶h̶e̶ ̶I̶n̶t̶e̶r̶n̶e̶t̶.̶ ̶I̶ ̶a̶l̶s̶o̶ ̶t̶r̶i̶e̶d̶ ̶u̶s̶i̶n̶g̶ ̶i̶t̶ ̶a̶n̶d̶ ̶m̶y̶ ̶s̶i̶t̶e̶ ̶s̶t̶o̶p̶p̶e̶d̶ ̶w̶o̶r̶k̶i̶n̶g̶.̶ ̶I̶ ̶c̶a̶n̶'̶t̶ ̶f̶i̶g̶u̶r̶e̶ ̶o̶u̶t̶ ̶w̶h̶a̶t̶ ̶r̶e̶d̶i̶r̶e̶c̶t̶i̶o̶n̶ ̶d̶o̶e̶s̶,̶ ̶m̶a̶y̶b̶e̶ ̶i̶t̶'̶s̶ ̶C̶l̶o̶u̶d̶F̶l̶a̶r̶e̶.̶
̶I̶ ̶k̶n̶o̶w̶ ̶a̶ ̶w̶a̶y̶ ̶t̶h̶a̶t̶ ̶s̶h̶o̶u̶l̶d̶ ̶w̶o̶r̶k̶.̶ ̶P̶l̶e̶a̶s̶e̶,̶ ̶c̶o̶u̶l̶d̶ ̶y̶o̶u̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶a̶ ̶w̶e̶b̶s̶i̶t̶e̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶ www ̶s̶u̶b̶d̶o̶m̶a̶i̶n̶.̶ ̶T̶h̶e̶n̶ ̶a̶l̶l̶ ̶s̶e̶t̶t̶i̶n̶g̶s̶ ̶w̶i̶l̶l̶ ̶w̶o̶r̶k̶ ̶w̶i̶t̶h̶o̶u̶t̶ ̶p̶r̶o̶b̶l̶e̶m̶s̶.̶
cinemapress install www.example.com

@zeldaroot
Copy link
Contributor

I found a code that does infinite redirection. Please try to delete it.

/config/production/nginx/conf.d/default.conf

server {

    listen 80;
    listen [::]:80;

    #ssl include /home/example.com/config/production/nginx/ssl.d/default.conf;

    server_name www.example.com;

    return 301 $scheme://example.com$request_uri;

}

If there are any problems, please let me know.

@seve26
Copy link
Author

seve26 commented Oct 11, 2021

Thanks a lot for your replies. I removed the code above and everything works fine with www.

I have an issue when I try to access the File Manager (Filetash). https://ftp.example.com/files/home/example.com/ redirect me on a 404 error, any thought?

Thanks again!
Best Regards

@zeldaroot
Copy link
Contributor

zeldaroot commented Oct 11, 2021

image

https://ftp.example.com/admin/backend

  1. Please use a forward slash / in the path setting.

@seve26
Copy link
Author

seve26 commented Oct 11, 2021

Thank you for replying, I also have 404 error when I try to access to https://ftp.example.com/admin/backend

ftp

Best Regards

@zeldaroot
Copy link
Contributor

Please try to Disable and Activate the file manager module.

@seve26
Copy link
Author

seve26 commented Oct 11, 2021

Thank's a lot for your help! Everything works fine! 👍

Best Regards.

@seve26
Copy link
Author

seve26 commented Oct 19, 2021

Sorry to reopen the issue but I would love to know a bit more about installing my own SSL certificate.

  1. If you have your own certificate, then do this:

    • First generate wildcard certificate cinemapress https
    • Now replace the generated certificates from the folders with your certificate files.

/config/production/nginx/ssl.d/default.conf

ssl_certificate /home/example.com/config/production/nginx/ssl.d/live/example.com/fullchain.pem;
ssl_certificate_key /home/example.com/config/production/nginx/ssl.d/live/example.com/privkey.pem;
ssl_dhparam /home/example.com/config/production/nginx/ssl.d/live/example.com/dhparam.pem;

I generated wildcard certificate using: cinemapress https then I uploaded www.example.com-bundle.crt and www_example_com.key to:

/home/example.com/config/production/nginx/ssl.d/live/example.com/

ssl

Then I changed the path in default.conf like this:

ssl_certificate /home/example.com/config/production/nginx/ssl.d/live/example.com/www.example.com-bundle.crt;
ssl_certificate_key /home/example.com/config/production/nginx/ssl.d/live/example.com/www_example_com.key;
ssl_dhparam /home/example.com/config/production/nginx/ssl.d/live/example.com/dhparam.pem;
  1. When I try to visit the site, I get Error 521 and after reuploading the original defaut.conf the site works again. What did I do wrong?

  2. Also regarding dhparam.pem, does I need to edit something or replacing it with another file?

  3. Using Filetash when I try to go to:

/home/example.com/config/production/nginx/ssl.d/live/example.com/fullchain.pem;

and

/home/example.com/config/production/nginx/ssl.d/live/example.com/privkey.pem;

I get Unknow Path:

ooops

It seems that fullchain.pem and privkey.pem doesn't exist, is that normal?

Thanks in advance.
Best Regards

@seve26 seve26 reopened this Oct 19, 2021
@zeldaroot
Copy link
Contributor

Hello,

I looked at the code and it looks like dhparam is generated after the certificates, therefore it is universal and should work with your certificates.
https://github.com/CinemaPress/CinemaPress/blob/master/cinemapress.sh#L987

Contact the support of the certification authority from which you took the certificate. Surely they know exactly how to put it in Nginx.

I do not know if filestash has support. Maybe if you write to them in the feedback form, they will respond.
https://www.filestash.app

@seve26
Copy link
Author

seve26 commented Oct 19, 2021

Thank you, I will write to the support of the certification authority where I bought it.
Best Regards

@seve26 seve26 closed this as completed Oct 19, 2021
@seve26 seve26 changed the title Refirect all non-www and www to https and www? Question Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants