質問編集履歴

1

confファイルを全体的に書き直し

2018/05/08 07:58

投稿

ruby_0ct
ruby_0ct

スコア57

test CHANGED
File without changes
test CHANGED
@@ -50,13 +50,9 @@
50
50
 
51
51
 
52
52
 
53
- default.confにも一応以下のような設定をしたのですが、意味ないですよね。
53
+ default.conf
54
-
54
+
55
- ```
55
+ ```
56
-
57
- hhtp {
58
-
59
- # メインのドメイン用設定
60
56
 
61
57
  server {
62
58
 
@@ -64,39 +60,131 @@
64
60
 
65
61
  server_name 〇〇.com;
66
62
 
63
+ return 301 https://〇〇.com$request_uri;
64
+
65
+ }
66
+
67
+
68
+
69
+ server {
70
+
71
+ listen 443 ssl;
72
+
73
+ server_name 〇〇.com;
74
+
75
+
76
+
77
+ ssl_certificate /etc/letsencrypt/live/〇〇.com;/fullchain.pem;
78
+
79
+ ssl_certificate_key /etc/letsencrypt/live/〇〇.com;/privkey.pem;
80
+
81
+
82
+
67
83
  charset UTF-8;
68
84
 
69
85
 
70
86
 
71
87
  location / {
72
88
 
89
+ try_files $uri $uri/ /index.php?$query_string;
90
+
73
- root /var/www/html;
91
+ root /var/www/html;
74
-
92
+
75
- index index.html index.htm index.php;
93
+ index index.html index.html index.php;
94
+
95
+
96
+
97
+ if ( -f $request_filename ) {
98
+
99
+ expires 30d;
100
+
101
+ break;
102
+
103
+ }
104
+
105
+ if (!-e $request_filename) {
106
+
107
+ rewrite ^.+?(/.*.php)$ $1 last;
108
+
109
+ rewrite ^ /index.php last;
110
+
111
+ }
76
112
 
77
113
  }
78
114
 
115
+
116
+
117
+ location ~ .php$ {
118
+
119
+ root /var/www/html;
120
+
121
+ fastcgi_pass 127.0.0.1:9000;
122
+
123
+ fastcgi_index index.php;
124
+
125
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
126
+
127
+ include fastcgi_params;
128
+
79
- }
129
+ }
80
-
81
-
82
-
83
- # サブドメイン用の設定
130
+
84
-
85
- server {
86
-
87
- listen 80;
88
-
89
- server_name サブドメイン名.〇〇.com;
90
-
91
- location / {
92
-
93
- root /var/www/サブドメイン名;
94
-
95
- proxy_pass http://127.0.0.1:3000;
96
-
97
- }
131
+ }
132
+
98
-
133
+ ```
134
+
135
+
136
+
137
+ nginx.conf
138
+
139
+ ```
140
+
141
+ user nginx;
142
+
143
+ worker_processes 1;
144
+
145
+ error_log /var/log/nginx/error.log warn;
146
+
147
+ pid /var/run/nginx.pid;
148
+
149
+
150
+
151
+ events {
152
+
153
+ worker_connections 1024;
154
+
99
- }
155
+ }
156
+
157
+
158
+
159
+ http {
160
+
161
+ include /etc/nginx/mime.types;
162
+
163
+ default_type application/octet-stream;
164
+
165
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
166
+
167
+ '$status $body_bytes_sent "$http_referer" '
168
+
169
+ '"$http_user_agent" "$http_x_forwarded_for"';
170
+
171
+
172
+
173
+ access_log /var/log/nginx/access.log main;
174
+
175
+ sendfile on;
176
+
177
+ keepalive_timeout 65;
178
+
179
+
180
+
181
+ include /etc/nginx/conf.d/default.conf;
182
+
183
+
184
+
185
+ include /etc/nginx/conf.d/サブドメイン名.conf;
186
+
187
+
100
188
 
101
189
  }
102
190