質問編集履歴

2

質問大幅に変更修正

2021/05/03 22:19

投稿

keykey
keykey

スコア6

test CHANGED
@@ -1 +1 @@
1
- failed (111: Connection refused) while connecting to upstreamのエラーついて[centos7 + Nginx]
1
+ Ghost やphpmyadminをhttpsで開こうとするとNot found 503 bad gatewayなる[centos7 + Nginx]
test CHANGED
@@ -1,179 +1,373 @@
1
1
  centos7 + Nginx の初心者です。皆様よろしくお願いいたします。
2
2
 
3
-
4
-
5
- fastcgi_pass の書き方について教えてください。
6
-
7
- CerbotのSSLでindex.htmlの表示やバーチャルドメインの設定などできるようになりました。
3
+ CerbotのSSLを使用しています。2つのドメインでindex.htmlなど静的ページ であればhttpsでの表示などできるようになりました。
4
+
8
-
5
+ GHOST CMSやphpmyadmin をインストールしてhttpでの表示はできますが、httpsで表示しようとするとNot found や bat gateway のエラーになってしまいます。
6
+
7
+
8
+
9
+ mywebsite1.com とmywebsite2.com の両方でSSLで の表示はできています。
10
+
9
- GHOST CMSや phpmyadminインストールして表示しようとしているのでが、
11
+ GHOST CMSやphpmyadmin は mywebsite1.comのドメインで行おうとしてい
10
-
11
- 以下のエラーが表示されます。
12
+
12
-
13
-
14
-
15
- connect() failed (111: Connection refused) while connecting to upstream, client:
16
-
17
-
18
-
19
- GHOSTは一度は教示をされたのですが、fastcgi_pass の書き方を変更したり、戻したりしているうちに表示されたり、されなかったりとしている状態です。
20
-
21
-
22
-
23
- 私はバリュードメインで2つドメインを取得し、NTTのINDIGOを使っています。
24
-
25
- 固定IP(独自ドメイン)でGHOST CMSや phpmyadminなどを表示するときに
26
-
27
- fastcgi_pass は 127.0.0.1:9000;のような値でいいのでしょうか?
28
-
29
-
30
-
31
- connect() failed (111: Connection refused) while connecting to upstream, client
32
-
33
- このエラーは fastcgi_pass の値が2つのファイルでずれているからということを
34
-
35
- 調べて値を変更しているのですが、どうしてもエラー変わらずページも表示されません。
13
+ nginx設定ファイルの書き方の問題だと思うのですが、何度書き方を変更しても上記の現象改善されません。
36
-
14
+
37
- 正しい書き方を教えていただけますでしょうか?よろしくお願いいたします。
15
+ 正しい記述のを教えていただけますでしょうか?よろしくお願いいたします。
16
+
17
+
18
+
19
+ できるかぎり設定ファイルを分けて、綺麗に書くようにしましたがこの程度のレベルです。よろしくお願いいたします。
38
20
 
39
21
 
40
22
 
41
23
  ```ここに言語を入力
42
24
 
43
-
44
-
45
-
46
-
47
- ■ vi /etc/nginx/conf.d/default.conf
48
-
49
-
50
-
51
- server {
52
-
53
- listen 80;
54
-
55
- server_name mywebiste.com;
56
-
57
-
58
-
59
- #charset koi8-r;
60
-
61
- #access_log /var/log/nginx/host.access.log main;
25
+ nginx -T
26
+
27
+ nginx: [warn] conflicting server name "mywebsite1.com" on 0.0.0.0:443, ignored
28
+
29
+ nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
30
+
31
+ nginx: configuration file /etc/nginx/nginx.conf test is successful
32
+
33
+
34
+
35
+
36
+
37
+ # configuration file /etc/nginx/nginx.conf:
38
+
39
+ user nginx;
40
+
41
+ worker_processes 1;
42
+
43
+
44
+
45
+ error_log /var/log/nginx/error.log warn;
46
+
47
+ pid /var/run/nginx.pid;
48
+
49
+
50
+
51
+ events {
52
+
53
+ worker_connections 1024;
54
+
55
+ }
56
+
57
+
58
+
59
+ http {
60
+
61
+ include /etc/nginx/mime.types;
62
+
63
+ default_type application/octet-stream;
64
+
65
+
66
+
67
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
68
+
69
+ '$status $body_bytes_sent "$http_referer" '
70
+
71
+ '"$http_user_agent" "$http_x_forwarded_for"';
72
+
73
+
74
+
75
+ access_log /var/log/nginx/access.log main;
76
+
77
+
78
+
79
+ sendfile on;
80
+
81
+ #tcp_nopush on;
82
+
83
+
84
+
85
+ keepalive_timeout 65;
86
+
87
+
88
+
89
+ #gzip on;
90
+
91
+
92
+
93
+ include /etc/nginx/conf.d/*.conf;
94
+
95
+
96
+
97
+ server {
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ location ~ .php$ {
106
+
107
+ fastcgi_pass 127.0.0.1:9000;
108
+
109
+ fastcgi_index index.php;
110
+
111
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
112
+
113
+ include fastcgi_params;
114
+
115
+ }
116
+
117
+
118
+
119
+ }
120
+
121
+ }
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ # configuration file /etc/nginx/conf.d/default.conf:
130
+
131
+ server {
132
+
133
+ listen 443 ssl;
134
+
135
+ server_name mywebsite2.com;
136
+
137
+ charset UTF-8;
138
+
139
+ access_log /var/log/nginx/mywebsite2-access.log main;
140
+
141
+ ssl_certificate /etc/letsencrypt/live/mywebsite2.com/fullchain.pem;
142
+
143
+ ssl_certificate_key /etc/letsencrypt/live/mywebsite2.com/privkey.pem;
144
+
145
+ root /var/www/html/mywebsite2;
146
+
147
+ }
148
+
149
+
150
+
151
+ server {
152
+
153
+ listen 443 ssl;
154
+
155
+ server_name mywebsite1.com;
156
+
157
+ charset UTF-8;
158
+
159
+ ssl_certificate /etc/letsencrypt/live/mywebsite1.com/fullchain.pem;
160
+
161
+ ssl_certificate_key /etc/letsencrypt/live/mywebsite1.com/privkey.pem;
162
+
163
+ root /var/www/html/mywebsite1;
164
+
165
+
166
+
167
+ location /phpMyAdmin {
168
+
169
+ root /usr/share;
170
+
171
+ index index.php index.html index.htm;
172
+
173
+ try_files $uri $uri/ /index.php?$query_string;
174
+
175
+ location ~ ^/phpMyAdmin/(.+.php)$ {
176
+
177
+ fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
178
+
179
+ fastcgi_index index.php;
180
+
181
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
182
+
183
+ include fastcgi_params;
184
+
185
+ fastcgi_intercept_errors on;
186
+
187
+ }
188
+
189
+ }
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ #error_page 404 /404.html;
198
+
199
+
200
+
201
+ # redirect server error pages to the static page /50x.html
202
+
203
+ #
204
+
205
+ error_page 500 502 503 504 /50x.html;
206
+
207
+ location = /50x.html {
208
+
209
+ root /usr/share/nginx/html;
210
+
211
+ }
212
+
213
+
214
+
215
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
216
+
217
+ #
218
+
219
+ #location ~ .php$ {
220
+
221
+ # proxy_pass http://127.0.0.1;
222
+
223
+ #}
224
+
225
+
226
+
227
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
228
+
229
+ #
230
+
231
+ #location ~ .php$ {
232
+
233
+ # root html;
234
+
235
+ # fastcgi_pass 127.0.0.1:9000;
236
+
237
+ # fastcgi_index index.php;
238
+
239
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
240
+
241
+ # include fastcgi_params;
242
+
243
+ #}
244
+
245
+
246
+
247
+ # deny access to .htaccess files, if Apache's document root
248
+
249
+ # concurs with nginx's one
250
+
251
+ #
252
+
253
+ #location ~ /.ht {
254
+
255
+ # deny all;
256
+
257
+ #}
258
+
259
+ }
260
+
261
+
262
+
263
+
264
+
265
+ # configuration file /etc/nginx/fastcgi_params:
266
+
267
+
268
+
269
+ fastcgi_param QUERY_STRING $query_string;
270
+
271
+ fastcgi_param REQUEST_METHOD $request_method;
272
+
273
+ fastcgi_param CONTENT_TYPE $content_type;
274
+
275
+ fastcgi_param CONTENT_LENGTH $content_length;
276
+
277
+
278
+
279
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
280
+
281
+ fastcgi_param REQUEST_URI $request_uri;
282
+
283
+ fastcgi_param DOCUMENT_URI $document_uri;
284
+
285
+ fastcgi_param DOCUMENT_ROOT $document_root;
286
+
287
+ fastcgi_param SERVER_PROTOCOL $server_protocol;
288
+
289
+ fastcgi_param REQUEST_SCHEME $scheme;
290
+
291
+ fastcgi_param HTTPS $https if_not_empty;
292
+
293
+
294
+
295
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
296
+
297
+ fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
298
+
299
+
300
+
301
+ fastcgi_param REMOTE_ADDR $remote_addr;
302
+
303
+ fastcgi_param REMOTE_PORT $remote_port;
304
+
305
+ fastcgi_param SERVER_ADDR $server_addr;
306
+
307
+ fastcgi_param SERVER_PORT $server_port;
308
+
309
+ fastcgi_param SERVER_NAME $server_name;
310
+
311
+
312
+
313
+ # PHP only, required if PHP was built with --enable-force-cgi-redirect
314
+
315
+ fastcgi_param REDIRECT_STATUS 200;
316
+
317
+
318
+
319
+ # configuration file /etc/nginx/conf.d/ghost.conf:
320
+
321
+ upstream ghost {
322
+
323
+ server 127.0.0.1:2368;
324
+
325
+ }
326
+
327
+ server {
328
+
329
+ listen 443 ssl http2;
330
+
331
+ listen 80;
332
+
333
+ server_name mywebsite1.com;
334
+
335
+
336
+
337
+ ssl_certificate /etc/letsencrypt/live/mywebsite1.com/fullchain.pem;
338
+
339
+ ssl_certificate_key /etc/letsencrypt/live/mywebsite1.com/privkey.pem;
340
+
341
+ access_log /var/log/nginx/ghost.access.log;
342
+
343
+ error_log /var/log/nginx/ghost.error.log;
344
+
345
+ proxy_buffers 16 64k;
346
+
347
+ proxy_buffer_size 128k;
62
348
 
63
349
 
64
350
 
65
351
  location / {
66
352
 
353
+ proxy_set_header X-Forwarded-Proto https;
354
+
355
+
356
+
357
+ proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
358
+
359
+ proxy_redirect off;
360
+
361
+ proxy_set_header Host $host;
362
+
67
- root /usr/share/nginx/html;
363
+ proxy_pass http://ghost;
68
-
364
+
69
- index index.html index.htm;
365
+ proxy_set_header X-Real-IP $remote_addr;
366
+
367
+ proxy_set_header X-Forwarded-For $proxy_add_X_forwarded_for;
70
368
 
71
369
  }
72
370
 
73
-
74
-
75
- location /phpMyAdmin {
76
-
77
- alias /usr/share/phpMyAdmin/;
78
-
79
- try_files $uri/ index.html index.php;
80
-
81
-
82
-
83
- location ~ ^/phpMyAdmin/(.+.php)$ {
84
-
85
- alias /usr/share/phpMyAdmin;
86
-
87
- fastcgi_pass 127.0.0.1:9000;
88
-
89
- fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$1;
90
-
91
- include fastcgi_params;
92
-
93
- fastcgi_intercept_errors on;
94
-
95
-
96
-
97
- }
371
+ }
98
-
99
- }
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
- #error_page 404 /404.html;
110
-
111
-
112
-
113
- # redirect server error pages to the static page /50x.html
114
-
115
- #
116
-
117
- error_page 500 502 503 504 /50x.html;
118
-
119
- location = /50x.html {
120
-
121
- root /usr/share/nginx/html;
122
-
123
- }
124
-
125
-
126
-
127
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
128
-
129
- #
130
-
131
-
132
-
133
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
134
-
135
- #
136
-
137
- #location ~ .php$ {
138
-
139
- # proxy_pass http://127.0.0.1;
140
-
141
- #}
142
-
143
-
144
-
145
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
146
-
147
- #
148
-
149
- #location ~ .php$ {
150
-
151
- # root html;
152
-
153
- # fastcgi_pass 127.0.0.1:9000;
154
-
155
- # fastcgi_index index.php;
156
-
157
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
158
-
159
- # include fastcgi_params;
160
-
161
- #}
162
-
163
-
164
-
165
- # deny access to .htaccess files, if Apache's document root
166
-
167
- # concurs with nginx's one
168
-
169
- #
170
-
171
- #location ~ /.ht {
172
-
173
- #
174
-
175
-
176
-
177
-
178
372
 
179
373
  ```

1

変更

2021/05/03 22:19

投稿

keykey
keykey

スコア6

test CHANGED
@@ -1 +1 @@
1
- failed (111: Connection refused) while connecting to upstream[centos7 + Nginx]
1
+ failed (111: Connection refused) while connecting to upstreamのエラーについて[centos7 + Nginx]
test CHANGED
@@ -1,4 +1,4 @@
1
- centos7 + Nginx の初心者です。よろしくお願いいたします。
1
+ centos7 + Nginx の初心者です。皆様よろしくお願いいたします。
2
2
 
3
3
 
4
4
 
@@ -35,6 +35,10 @@
35
35
  調べて値を変更しているのですが、どうしてもエラーが変わらずページも表示されません。
36
36
 
37
37
  正しい書き方を教えていただけますでしょうか?よろしくお願いいたします。
38
+
39
+
40
+
41
+ ```ここに言語を入力
38
42
 
39
43
 
40
44
 
@@ -167,3 +171,9 @@
167
171
  #location ~ /.ht {
168
172
 
169
173
  #
174
+
175
+
176
+
177
+
178
+
179
+ ```