Score:0

apache2: /etc/hosts won't redirect to apache2

ge flag

I have newly installed apache2 and by visiting localhost apache2 is shown to be up and running. I want the same to happen when I put app in the browser. When I do try to go visit app the browser gives a Unable to connect message.

What I have done so far

I changed my etc/hosts/ file to include app.

127.0.0.1   localhost app
127.0.1.1   ubuntu
...

I would then expect http://app/ to resolve to the apache2 page(as I want it to), but that doesn't happen. Therefore I tried to ping app. This worked and was shown to resolve to 127.0.0.1.

Next I tried to restart apache2, but the result stayed the same.

Why do I get Unable to connect message and how do I make it redirect me to apache2?

EDIT:

I've tried to add app here too.

<VirtualHost *:80>
    ServerName app
    ServerAlias www.app
    ServerAdmin webmaster@app
    DocumentRoot /var/www/app

    ErrorLog ${APACHE_LOG_DIR}/app-error.log
    CustomLog ${APACHE_LOG_DIR}/app-access.log combined
</VirtualHost>

I then run the command a2ensite app.conf and then I restart apache2 with systemctl reload apache2.

Still when I put app in the browser field I get a Unable to connect message.

Michael Hampton avatar
cz flag
Hmm. Don't use a browser, but something that will actually give you a useful error message e.g. curl.
Mr Krisey avatar
ge flag
That worked. Thanks. Why does curl work, but not the browser?
Michael Hampton avatar
cz flag
Did you actually use the literal string `app`? You can't do that. It is a real live domain on the Internet and you don't own it. Use something else, like a subdomain of your own domain name.
Mr Krisey avatar
ge flag
I used actually used `app.dev`.
Michael Hampton avatar
cz flag
That's also a real live domain, you don't own it, and every domain in `dev` must use HTTPS. Browsers strictly enforce this.
Mr Krisey avatar
ge flag
Thank you again! That fixed my problem entirely. Is it a standard of some sorts that `dev` and probably others like `com` enforce https?
Michael Hampton avatar
cz flag
https://serverfault.com/q/1067229/126632
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.