Can't access my owncloud without typing https:// first

Hello,

Im using this tutorial http://www.techjawab.com/search/label/Raspberry%20Pi to setup my ownCloud and everything setup and working correctly even have it access from outside my local network. Although I can't seem to understand why every new visitors or new devices need to type in https://example.com for it to work. Its very annoying since user typical like myself can't be bother to type in the full URL. I have check the A Record and applied it correctly with @ and pointing to my public IP address. I don't know what the problem is.

Please help me, thank You

You can redirect your normal http to https. Edit your config file /etc/apache2/sites-available/000-default.conf and add a Redirect permanent after that it should look similar to:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        Redirect permanent / https://myhostname/owncloud
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Hi,

I am using nginx in the tutorial, inside /etc/nginx/sites-available/default I can't seem to fit in the code

Redirect permanent / https://myhostname/owncloud

I get error when restart nginx

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

This is my actual file 'default'

server {
listen 80;
server_name mydomain.com
return 301 https://$server_name$request_uri; # enforce https
}

server {
listen 443 ssl;
server_name mydomain.com
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
root /var/www/owncloud;

and some more down the line.

I try to google out redirect permanent for nginx but none seem to work in my case...

Thank You

Oh sorry, my example was for apache. Your version with the redirect looks good. You are sure there is no competing configuration? Did you restart the webserver?

For configuration help with nginx its also possible to contact the nginx community:

http://nginx.org/en/support.html

Seems your firewall is still blocking port 80.

If you're running fedora, centos 7 or rhel 7 you can open port 80 by running following command:

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

For other distributions consider its manual.

Your configuration is missing a semicolon at the end of the server_name statements (in both server blocks):

server {
           listen 80;
           server_name mydomain.com
           return 301 https://$server_name$request_uri;    # enforce https
}

server {
           listen 443 ssl;
           server_name mydomain.com
           add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";

You can execute sudo nginx -t to verify you have a valid nginx configuration.

@timm2k : I'm using raspbian jessie
@litemaster: the ; at the end was a miss cut and paste, :slight_smile: so sudo nginx -t is successfully test

Thank you for all replied, although I am still looking for a solution.

Then what does journalctl -xn show after nginx fails to start up?
I may not be related to ownCloud at all.

How should this be set for someone not utilizing domain name. I access using public ip address and non-standard port. I would think if I entered
10.0.0.1:1443/owncloud ------> HTTPS://10.0.0.1:1443/owncloud (This results in error 400)
10.0.0.1:8080/owncloud ------> HTTP://10.0.0.1:8080/owncloud (this works but http is not added to beginning which is fine I guess)

I don't want all HTTP traffic forwarded to HTTPS as I deal with some people whose computers will not connect to self-signed certificates. In this case I need HTTP to work. I suppose I could force HTTPS (redirect) and remove in the event it is not needed for the short time, I am OK with that.

(Bad Request
Your browser sent a request that this server could not understand.

Reason: You're speaking plain HTTP to an SSL-enabled server port.

_ Instead use the HTTPS scheme to access this URL, please._

Apache/2.4.7 (Ubuntu) Server at xxx.xxx.xxx.xxx Port 1443)

Thanks.

Your problem is different, please open a new topic and don't hijack this one.

I reckon I'll make another thread, although I would think the title of this thread matches exactly what I need to find solution for.