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

質問編集履歴

4

追記

2020/04/13 00:57

投稿

Y.NINOMIYA
Y.NINOMIYA

スコア32

title CHANGED
File without changes
body CHANGED
@@ -92,8 +92,48 @@
92
92
 
93
93
  index.cgi
94
94
  ```cgi
95
+ #!/usr/local/bin/python      //Pythonのパスを追記
96
+
95
97
  # -*- coding: utf-8 -*-      //文字コードを追記
98
+ import cgitb
99
+ cgitb.enable()
96
100
 
101
+ from wsgiref.handlers import CGIHandler
102
+ from app import app
103
+
104
+ from sys import path
105
+
106
+ path.insert(0, '/**ユーザ名**/www/')       //Flask、index.cgiを置いているディレクトリに変更
107
+ from app import app
108
+ class ProxyFix(object):
109
+ def __init__(self, app):
110
+ self.app = app
111
+ def __call__(self, environ, start_response):
112
+
113
+ environ['SERVER_NAME'] = "**ユーザ名**.ne.jp" //サーバネームを変更
114
+ environ['SERVER_PORT'] = "80"
115
+ environ['REQUEST_METHOD'] = "GET"
116
+ environ['SCRIPT_NAME'] = ""
117
+ environ['PATH_INFO'] = "/"
118
+ environ['QUERY_STRING'] = ""
119
+ environ['SERVER_PROTOCOL'] = "HTTP/1.1"
120
+ return self.app(environ, start_response)
121
+ if __name__ == '__main__':
122
+ app.wsgi_app = ProxyFix(app.wsgi_app)
123
+ CGIHandler().run(app)
124
+ ```
125
+
126
+ index.cgiには`chmod 755 index.cgi`で実行権限を付与
127
+
128
+ エラーは依然そのままです。
129
+
130
+ ### 追記②
131
+ CGIの#!は必ず1行目ということを知りませんでした。失礼しました。
132
+
133
+ index.cgi
134
+ ```cgi
135
+ # -*- coding: utf-8 -*-      //文字コードを追記
136
+
97
137
  #!/usr/local/bin/python      //Pythonのパスを追記
98
138
 
99
139
  import cgitb
@@ -104,7 +144,7 @@
104
144
 
105
145
  from sys import path
106
146
 
107
- path.insert(0, '/miyablo/www/')       //Flask、index.cgiを置いているディレクトリに変更
147
+ path.insert(0, '/**ユーザ名**/www/')       //Flask、index.cgiを置いているディレクトリに変更
108
148
  from app import app
109
149
  class ProxyFix(object):
110
150
  def __init__(self, app):
@@ -124,6 +164,9 @@
124
164
  CGIHandler().run(app)
125
165
  ```
126
166
 
127
- index.cgiには`chmod 755 index.cgi`で実行権限を付与
128
-
129
- エラーは依然そのまです。
167
+ 他のエラーが吐かれした
168
+ ```error
169
+ [Mon Apr 13 09:52:33.316835 2020] [http:error] [pid 96285] [client 126.***.103.**:0] AH02429: Response header name '<!--' contains invalid characters, aborting request
170
+ ```
171
+ ヘッダーに<!--という不正な文字があるためリクエストを中止したって内容ということはわかります。
172
+ しかし、ヘッダーの設定はどこにも記述していないので対処しようがありません、、、、

3

修正依頼を受けての追記

2020/04/13 00:57

投稿

Y.NINOMIYA
Y.NINOMIYA

スコア32

title CHANGED
File without changes
body CHANGED
@@ -85,4 +85,45 @@
85
85
 
86
86
 
87
87
  どなたか詳しい方
88
- 回答よろしくお願いします。
88
+ 回答よろしくお願いします。
89
+
90
+ ### 追記
91
+ index.cgiを編集しました。
92
+
93
+ index.cgi
94
+ ```cgi
95
+ # -*- coding: utf-8 -*-      //文字コードを追記
96
+
97
+ #!/usr/local/bin/python      //Pythonのパスを追記
98
+
99
+ import cgitb
100
+ cgitb.enable()
101
+
102
+ from wsgiref.handlers import CGIHandler
103
+ from app import app
104
+
105
+ from sys import path
106
+
107
+ path.insert(0, '/miyablo/www/')       //Flask、index.cgiを置いているディレクトリに変更
108
+ from app import app
109
+ class ProxyFix(object):
110
+ def __init__(self, app):
111
+ self.app = app
112
+ def __call__(self, environ, start_response):
113
+
114
+ environ['SERVER_NAME'] = "**ユーザ名**.ne.jp" //サーバネームを変更
115
+ environ['SERVER_PORT'] = "80"
116
+ environ['REQUEST_METHOD'] = "GET"
117
+ environ['SCRIPT_NAME'] = ""
118
+ environ['PATH_INFO'] = "/"
119
+ environ['QUERY_STRING'] = ""
120
+ environ['SERVER_PROTOCOL'] = "HTTP/1.1"
121
+ return self.app(environ, start_response)
122
+ if __name__ == '__main__':
123
+ app.wsgi_app = ProxyFix(app.wsgi_app)
124
+ CGIHandler().run(app)
125
+ ```
126
+
127
+ index.cgiには`chmod 755 index.cgi`で実行権限を付与
128
+
129
+ エラーは依然そのままです。

2

表現の修正

2020/04/12 18:33

投稿

Y.NINOMIYA
Y.NINOMIYA

スコア32

title CHANGED
File without changes
body CHANGED
@@ -79,7 +79,7 @@
79
79
 
80
80
  ### 現状
81
81
  https://qiita.com/ninoko1995/items/8b01fd02bada3a2fa794
82
- 上の記事を参考に構築していきました。
82
+ の記事を参考に構築していきました。
83
83
  記事では`python index.cgi`と、直接動かして500番エラーになり上のソースコードのindex.cgiに修正しエラーを解消させていました。
84
84
  ただ、自分の環境でもindex.cgiを修正し`python index.cgi`を実行したらステータスは200番で無事接続されたのですが、ブラウザの方からは依然500番エラーのままでした。
85
85
 

1

誤字の修正

2020/04/12 10:06

投稿

Y.NINOMIYA
Y.NINOMIYA

スコア32

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  ```error
4
4
  [Sun Apr 12 18:40:40.314361 2020] [cgi:error] [pid 96285] [client 126.**.103.**:0] AH01215: suexec policy violation: see suexec log for more details: /home/**ユーザ名**/www/index.cgi
5
5
  [Sun Apr 12 18:40:40.314471 2020] [cgi:error] [pid 96285] [client 126.**.103.**:0] End of script output before headers: index.cgi
6
- [Sun Apr 12 18:40:40.352756 2020] [cgi:error] [pid 10072] [client 126.**.103.**:0] AH01215: suexec policy violation: see suexec log for more details: /home/room-share/www/index.cgi, referer: http://**ユーザ名**.sakura.ne.jp/
6
+ [Sun Apr 12 18:40:40.352756 2020] [cgi:error] [pid 10072] [client 126.**.103.**:0] AH01215: suexec policy violation: see suexec log for more details: /home/**ユーザ名**/www/index.cgi, referer: http://**ユーザ名**.sakura.ne.jp/
7
7
  [Sun Apr 12 18:40:40.352895 2020] [cgi:error] [pid 10072] [client 126.**.103.**:0] End of script output before headers: index.cgi, referer: http://**ユーザ名**.sakura.ne.jp/
8
8
  ```
9
9
  アクセス元IPとユーザ名は一部伏せてあります。