1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>First Website | garhve's gibberish</title>
<link rel="shortcut icon" type="image/png" href="/images/favicon.png">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link id="stylesheet" rel="stylesheet" type="text/css" href="/dark.css">
<script type="text/javascript" src="/js/theme.js"></script>
</head>
<div class="header">
<div class="site_title">
<p><a href="/"><img src="https://blog.garhve.com/images/logo.png" alt="garhve's gibberish"
width="70" height=auto></a></p>
<p><a href="/"> garhve's gibberish</a></p>
</div>
<div class="menu">
<!-- <a href="/tags">tags</a>
--><a href="/categories">categories</a>
</div>
</div>
<body onload="getTheme()">
<section class="section">
<div class="container">
<p>
<div class="title_postpage">First Website</div>
</p>
<p>
<div class="date_postpage">2022-08-10</div>
<div class="taxonomies_postpage">
<a href="https://blog.garhve.com/categories/period/">/period</a>
 <a href="https://blog.garhve.com/tags/gibberish/">#gibberish</a>
</div>
</p>
<p>
<p>So now I can say my website is on.. even though it just literally has nothing but a printing <em>hello</em>
<img src="https://assets.garhve.com/pictures/screenshots/2022/08/2751557406.png" alt="FirstWebsite.png" /></p>
<p>I got this <em>garhve.com</em> domain on namesilo for $9.95 per year, it's really cheap! I always want a domain that is .com suffix.</p>
<p>Now, the web is https, this is a bit difficult for me.</p>
<p>Due to personal interest, I didn't choose frame to base my website. I use <strong>Nginx</strong> but I don't familiar with it. making it shows my content is not that difficult even that I don't know much fancy state, but I stucked on SSL.</p>
<p>In order to use https instead of http, I choosed <strong>let's encrypt</strong>, which is good for me and it's free. However, I can only getting my non-www domain working. when it comes to www domain, it still http.</p>
<p>I found solutions all about using return to returning https, but it won't work</p>
<pre data-lang="nginx" style="background-color:#2e3440;color:#d8dee9;" class="language-nginx "><code class="language-nginx" data-lang="nginx"><span>server {
</span><span> server_name www.garhve.com;
</span><span> return 301 https://www.garhve.com$request_uri
</span><span>}
</span></code></pre>
<p>This would return me a 404 error...</p>
<p>After searching and searching, I found where i was getting wrong.</p>
<p>Above statement only return https-www which doesn't hold any contents, all I need is to redirect the https-www to https-non-www.</p>
<p>So, change to this one</p>
<pre data-lang="nginx" style="background-color:#2e3440;color:#d8dee9;" class="language-nginx "><code class="language-nginx" data-lang="nginx"><span>server {
</span><span> listen 80;
</span><span> server_name www.garhve.com garhve.com;
</span><span> return 301 https://garhve.com$request_uri;
</span><span>} # this block will redirect http-both to https-both
</span><span>
</span><span>server {
</span><span> listen 443 ssl http2; #http2 is newer and more secure http
</span><span> listen [::]:443 ssl http2;
</span><span>
</span><span> server_name www.garhve.com;
</span><span> include /path_to_cert_file;
</span><span> return 301 https://garhve.com$request_uri;
</span><span>} # this block will redirect https-www to https-non-www
</span><span>
</span><span>server {
</span><span> listen 443 ssl http2;
</span><span> listen [::]:443 ssl http2;
</span><span>
</span><span> server_name garhve.com;
</span><span> include /path_to_cert_file;
</span><span>
</span><span> #location to real content
</span><span>} # this block is where we hold web content.
</span></code></pre>
<p>It will redirect <em>https-www</em> to <em>https-non-www</em>. Now, both domain will point to same location -- my home page.</p>
</p>
</div>
</section>
</body>
<div class="footer">
 © garhve
</div>
</html>
|