teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

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

2018/05/08 07:58

投稿

ruby_0ct
ruby_0ct

スコア57

title CHANGED
File without changes
body CHANGED
@@ -24,30 +24,74 @@
24
24
  }
25
25
  ```
26
26
 
27
- default.confにも一応以下のような設定をしたのですが、意味ないですよね。
27
+ default.conf
28
28
  ```
29
- hhtp {
30
- # メインのドメイン用設定
31
29
  server {
32
30
  listen 80;
33
31
  server_name 〇〇.com;
32
+ return 301 https://〇〇.com$request_uri;
33
+ }
34
+
35
+ server {
36
+ listen 443 ssl;
37
+ server_name 〇〇.com;
38
+
39
+ ssl_certificate /etc/letsencrypt/live/〇〇.com;/fullchain.pem;
40
+ ssl_certificate_key /etc/letsencrypt/live/〇〇.com;/privkey.pem;
41
+
34
42
  charset UTF-8;
35
43
 
36
44
  location / {
45
+ try_files $uri $uri/ /index.php?$query_string;
37
- root /var/www/html;
46
+ root /var/www/html;
38
- index index.html index.htm index.php;
47
+ index index.html index.html index.php;
48
+
49
+ if ( -f $request_filename ) {
50
+ expires 30d;
51
+ break;
52
+ }
53
+ if (!-e $request_filename) {
54
+ rewrite ^.+?(/.*.php)$ $1 last;
55
+ rewrite ^ /index.php last;
56
+ }
39
57
  }
58
+
59
+ location ~ .php$ {
60
+ root /var/www/html;
61
+ fastcgi_pass 127.0.0.1:9000;
62
+ fastcgi_index index.php;
63
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
64
+ include fastcgi_params;
65
+ }
40
66
  }
67
+ ```
41
68
 
42
- # サブドメイン用の設定
69
+ nginx.conf
70
+ ```
43
- server {
71
+ user nginx;
44
- listen 80;
45
- server_name サブドメイン名.〇〇.com;
72
+ worker_processes 1;
46
- location / {
73
+ error_log /var/log/nginx/error.log warn;
47
- root /var/www/サブドメイン名;
74
+ pid /var/run/nginx.pid;
75
+
76
+ events {
48
- proxy_pass http://127.0.0.1:3000;
77
+ worker_connections 1024;
49
- }
50
78
  }
79
+
80
+ http {
81
+ include /etc/nginx/mime.types;
82
+ default_type application/octet-stream;
83
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
84
+ '$status $body_bytes_sent "$http_referer" '
85
+ '"$http_user_agent" "$http_x_forwarded_for"';
86
+
87
+ access_log /var/log/nginx/access.log main;
88
+ sendfile on;
89
+ keepalive_timeout 65;
90
+
91
+ include /etc/nginx/conf.d/default.conf;
92
+
93
+ include /etc/nginx/conf.d/サブドメイン名.conf;
94
+
51
95
  }
52
96
  ```
53
97