格式错误的数据包:Django 管理嵌套表单无法提交,连接已重置
Malformed Packet: Django admin nested form can't submit, connection was reset
我有一个 django 嵌套管理表单,下面的代码是我的 admin.py
文件内容:
# -*- coding:utf-8 -*-
from django.db.models import Q
from django import forms
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib import admin
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
from django.forms.utils import flatatt
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _, ugettext
from django.contrib.auth.models import Group, Permission
from nested_admin.nested import NestedStackedInline, NestedModelAdmin
from HomeMakers.apps.system.models import Dependant, Benefit, User, \
Unit, Stack, Parking
from mtools.fields import UniqueValueWidget, PersianDateField
class DependantAdminForm(forms.ModelForm):
model = Dependant
birth_date = PersianDateField(label=u'تاریخ تولد')
class DependantAdmin(NestedStackedInline):
model = Dependant
form = DependantAdminForm
extra = 0
exclude = ['changed_status', 'new_obj']
can_delete = True
class BenefitSubAdmin(admin.TabularInline):
model = Benefit
extra = 1
min_num = 0
exclude = ['changed_status', 'new_obj']
can_delete = True
class NewUserAdminForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = User
username = forms.RegexField(label=u"کد ملی", max_length=30, regex=r'^\d{8,10}$',
widget=UniqueValueWidget,
error_messages={'invalid': u"مقدار وارد شده قابل قبول نمیباشد."})
birth_date = PersianDateField(from_year=1290, to_year=1400, label=_('Birth Date'))
start_date = PersianDateField(from_year=1290, to_year=1400, label=u"تاریخ شروع به کار")
def clean_username(self):
# Since User.username is unique, this check is redundant,
# but it sets a nicer error message than the ORM. See #13147.
username = self.cleaned_data["username"]
if User.objects.filter(username=username).count() > 0:
raise forms.ValidationError(self.error_messages['duplicate_username'])
return username
class ReadOnlyPasswordHashWidget(forms.Widget):
def render(self, name, value, attrs):
encoded = value
final_attrs = self.build_attrs(attrs)
if not encoded or encoded.startswith(UNUSABLE_PASSWORD_PREFIX):
summary = mark_safe(u"<strong>%s</strong>" % _("No password set."))
else:
try:
hasher = identify_hasher(encoded)
except ValueError:
summary = mark_safe(u"<strong>%s</strong>" % _(
"Invalid password format or unknown hashing algorithm."))
else:
summary = u'''format_html_join('',
"<strong>{0}</strong>: {1} ",
((ugettext(key), value)
for key, value in hasher.safe_summary(encoded).items())
)'''
return format_html(u"<div{0}>{1}</div>", flatatt(final_attrs), summary)
class ReadOnlyPasswordHashField(forms.Field):
widget = ReadOnlyPasswordHashWidget
def __init__(self, *args, **kwargs):
kwargs.setdefault("required", False)
super(ReadOnlyPasswordHashField, self).__init__(*args, **kwargs)
def bound_data(self, data, initial):
# Always return initial because the widget doesn't
# render an input field.
return initial
def _has_changed(self, initial, data):
return False
class EditUserAdminForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = User
birth_date = PersianDateField(from_year=1290, to_year=1400, label=_('Birth Date'))
start_date = PersianDateField(from_year=1290, to_year=1400, label=u"تاریخ شروع به کار")
password = ReadOnlyPasswordHashField(label=_("Password"),
help_text=_("Raw passwords are not stored, so there is no way to see "
"this user's password, but you can change the password "
"using <a href=\"password/\">this form</a>."))
error_messages = {'duplicate_username': 'An user by this international code already exists.'}
def __init__(self, *args, **kwargs):
super(EditUserAdminForm, self).__init__(*args, **kwargs)
self.fields['username'] = forms.RegexField(label=u"کد ملی", max_length=30, regex=r'^\d{8,10}$',
widget=UniqueValueWidget(),
error_messages={'invalid': u"مقدار وارد شده قابل قبول نمیباشد."})
self.fields['username'].widget.attrs['value'] = self.instance.username
def clean_username(self):
# Since User.username is unique, this check is redundant,
# but it sets a nicer error message than the ORM. See #13147.
username = self.cleaned_data["username"]
if username != self.instance.username and User.objects.filter(username=username).count() > 0:
raise forms.ValidationError(self.error_messages['duplicate_username'])
return username
class UnitForm(forms.ModelForm):
model = Unit
installment_begin_date = PersianDateField(label=u'تاریخ شروع اقساط')
class StackSubAdmin(NestedStackedInline):
model = Stack
extra = 1
class ParkingSubAdmin(NestedStackedInline):
model = Parking
extra = 1
class UnitSubAdmin(NestedStackedInline): #(admin.StackedInline):
model = Unit
form = UnitForm
extra = 0
inlines = [ParkingSubAdmin, StackSubAdmin]
exclude = ['sum_of_pays', 'parkings', 'warehouse']
class UserAdmin(AuthUserAdmin, NestedModelAdmin):
model = User
ordering = ['last_name']
list_per_page = 10
add_form = NewUserAdminForm
form = EditUserAdminForm
list_display = ['user_thumb', 'first_name', 'last_name']
list_filter = ['units__project', 'groups']
formfield_overrides = {
# models.DateField: {'widget': PersianDateWidget}
}
'''fields = (
'username', 'password', 'first_name', 'last_name', 'email',
'gender', 'birth_date', 'picture', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'international_code', 'job_field', 'self_employed_job_name', 'employment_type',
'start_date', 'is_retired'
)'''
inlines = [DependantAdmin, UnitSubAdmin] # & BenefitSubAdmin
def get_fieldsets(self, request, obj=None):
key_fields = {'fields': ('username', 'password1', 'password2')}
if obj is not None:
key_fields = {'fields': ('username', 'password')}
fieldsets = (
(None, key_fields),
(u'اطلاعات تکمیلی', {'fields': (
'first_name', 'last_name', 'email',
'gender', 'birth_date', 'academic_degree', 'picture', 'international_card_scaned_file',
'certificate_scaned_file_page1', 'certificate_scaned_file_page2', 'academic_degree_scaned_file',
'job_edict_document', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'job_field', 'self_employed_job_name', 'employment_type', 'start_date',
'is_retired'
)}
),
(u'سطوح دسترسی', {'fields': ('is_active', 'is_staff', 'groups')})
# , 'user_permissions', 'is_superuser')}),
# (u'تاریخ های مهم', {'fields': ('last_login', 'date_joined')})
)
if request.user.is_superuser:
fieldsets = (
(None, key_fields),
(u'اطلاعات تکمیلی', {'fields': (
'first_name', 'last_name', 'email',
'gender', 'birth_date', 'academic_degree', 'picture', 'international_card_scaned_file',
'certificate_scaned_file_page1', 'certificate_scaned_file_page2', 'academic_degree_scaned_file',
'job_edict_document', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'job_field', 'self_employed_job_name', 'employment_type', 'start_date',
'is_retired'
)}
),
(u'سطوح دسترسی', {'fields': (
'is_active',
'is_staff',
'is_superuser',
'user_permissions',
'groups'
)
})
# (u'تاریخ های مهم', {'fields': ('last_login', 'date_joined')})
)
return fieldsets
def get_queryset(self, request):
if request.user.is_superuser:
return User.objects.all()
return User.objects.filter(is_superuser=False)
class GroupAdmin(admin.ModelAdmin):
model = Group
filter_horizontal = ('permissions',)
def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "permissions" and not request.user.is_superuser:
kwargs["queryset"] = Permission.objects.exclude(
Q(codename__startswith='add_') |
Q(codename__startswith='change_') |
Q(codename__startswith='delete_')
)
return super(GroupAdmin, self).formfield_for_manytomany(
db_field,
request,
**kwargs
)
def save_model(self, request, group, form, change):
perms = []
for p in group.permissions.all():
if p.codename.startswith('add_') or \
p.codename.startswith('change_') or \
p.codename.startswith('delete_'):
perms.append(p)
super(GroupAdmin, self).save_model(request, group, form, change)
form.cleaned_data['permissions'] = list(
form.cleaned_data['permissions']
)
if not request.user.is_superuser:
form.cleaned_data['permissions'].extend(perms)
form.cleaned_data['permissions'] = list(set(
form.cleaned_data['permissions']))
group.save()
# register new user admin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.unregister(Group)
admin.site.register(Group, GroupAdmin)
当我在本地主机上开发和 运行 devserver 时,一切正常,但在服务器和域上,我无法通过 连接已重置 提交此表单信息。
下面的代码是我的 apache2 配置:
<VirtualHost *:80>
DocumentRoot "/var/www/wordpress"
# ServerName localhost
# Alias /wordpress /var/www/wordpress
# <Directory /var/www/wordpress>
# Options Indexes FollowSymLinks
# AllowOverride None
# Order Deny,Allow
# Allow from all
# </Directory>
WSGIScriptAlias /m3s /var/www/m3s/HomeMakers/wsgi.py
#ProxyPass /m3s/ http://127.0.0.1:8000/
#ProxyPassReverse /m3s/ http://127.0.0.1:8000/
#<Proxy http://127.0.0.1:8000/m3s/>
# Order Allow,Deny
# Allow from all
#</Proxy>
# WSGIDaemonProcess sentry python-path=/var/www/sentry/venv/lib/python2.7/site-packages
# WSGIScriptAlias /exceptions/tracker /var/www/sentry/venv/lib/python2.7/site-packages/sentry/wsgi.py
Alias /ufiles /var/www/m3s/media_files
Alias /static /var/www/m3s/sfiles
Alias /_static /var/www/sentry/venv/lib/python2.7/site-packages/sentry/static
Alias /mydb/admin /usr/share/phpmyadmin
<Directory "/var/www/m3s/HomeMakers/">
Options +ExecCGI
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/m3s/sfiles/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我也尝试同时使用 uwsgi 和 mod_proxy 但我的问题没有解决。在我通过 access.log 和我的服务器端口 80 监控 tshark 之后,tshard 向我显示了这个请求,但是在 access.log 文件我看不到任何变化...
Apache 以信息模式登录:
[Sun Jan 29 21:15:47.896062 2017] [wsgi:warn] [pid 7596] mod_wsgi: Compiled for Python/2.7.11.
[Sun Jan 29 21:15:47.896100 2017] [wsgi:warn] [pid 7596] mod_wsgi: Runtime using Python/2.7.11+.
[Sun Jan 29 21:15:47.898887 2017] [mpm_prefork:notice] [pid 7596] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.11+ configured -- resuming normal operations
[Sun Jan 29 21:15:47.898913 2017] [core:notice] [pid 7596] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jan 29 21:16:43.833245 2017] [wsgi:info] [pid 7599] [client 84.241.62.118:44316] mod_wsgi (pid=7599, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'.
[Sun Jan 29 21:16:45.317557 2017] [wsgi:error] [pid 7599] DEBUG 2017-01-29 21:16:45,317 base 7599 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a12c>
[Sun Jan 29 21:16:47.484799 2017] [wsgi:info] [pid 7602] [client 84.241.62.118:42751] mod_wsgi (pid=7602, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'., referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619
[Sun Jan 29 21:16:48.899865 2017] [wsgi:error] [pid 7602] DEBUG 2017-01-29 21:16:48,899 base 7602 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a12c>
[Sun Jan 29 21:17:33.961983 2017] [wsgi:info] [pid 7603] [client 84.241.62.118:20515] mod_wsgi (pid=7603, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'., referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619
[Sun Jan 29 21:17:35.360116 2017] [wsgi:error] [pid 7603] DEBUG 2017-01-29 21:17:35,360 base 7603 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a1ac>
还有我的access.log文件内容:
192.0.102.40 - - [29/Jan/2017:22:37:30 +0330] "HEAD / HTTP/1.1" 200 372 "-" "jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)"
xxx.241.62.118 - - [29/Jan/2017:22:37:56 +0330] "GET /m3s/m3s-panel/members/user/ HTTP/1.1" 200 4627 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:37:57 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:51 +0330] "GET /m3s/m3s-panel/members/user/?q=0065231619 HTTP/1.1" 200 4195 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:51 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/?q=0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:54 +0330] "GET /m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619 HTTP/1.1" 200 14967 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/?q=0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:55 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:55 +0330] "GET /m3s/_nested_admin/server-data.js HTTP/1.1" 200 388 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
我在 ServerFault 站点上的相关问题:
https://serverfault.com/questions/827813/apache-respons-to-get-but-not-to-post
更新:
我再次 运行 tshark 并看到下面 important 行:
7 0.754812317 5.113.18.90 -> xxx.156.28.145 HTTP 1434 POST /m3s/m3s-panel/members/user/501/ HTTP/1.1 [Malformed Packet]
下面是我的浏览器"Request Payload":
Content-Type: multipart/form-data; boundary=---------------------------51995842320268179811054389612
Content-Length: 4614
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="csrfmiddlewaretoken"
STMAQ1bSTuWsl9CelQBK5S2QjUKIfZ1Z
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="username"
9265291619
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="first_name"
اعظم
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="last_name"
جعفری
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="email"
jafariphd@ut.ac.ir
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="gender"
0
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_0"
15
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_1"
6
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_2"
1356
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="academic_degree"
5
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="academic_degree_scaned_file"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="job_edict_document"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_no"
11909
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_place"
تهران
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="address"
تهران -میدان پاستور-خ پاستور غربی-خ آژیده-کوچه آفین-پ 7-طبقه اول غربی
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="home_phone"
66915902
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="work_phone"
66409696
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="mobile"
09125114282
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="personnel_code"
26687
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="job_field"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="self_employed_job_name"
کارشناس معماری
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="employment_type"
3
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_0"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_1"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_2"
1385
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="is_active"
on
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="is_staff"
on
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="groups"
3
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="_continue"
ذخیره و ادامهٔ ویرایش
-----------------------------51995842320268179811054389612--
但现在我的问题是这个问题是如何发生的,我该如何解决?
我们在 Cent OS 64 位 Apache 2.4 的新安装系统上遇到了同样的问题。 Apache 有时会断开连接,它落后于 nginx,所以我们经常遇到 502 网关错误。日志中没有任何内容,没有启用调试,没有崩溃转储等等。
解决问题的唯一解决方案 - rebuild/reinstall Apache 完全。我们在将调试输出代码添加到 Apache 源并重建时找到了这个解决方案,想知道我们的调试代码如何解决问题。但它只是 re-build.
P.S。还要仔细遵循有关调试 WSGI http://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html
的建议
我允许我的朋友访问我的 VPS,然后他告诉我我的问题与 wordpress 有关,并在页面加载并按下提交后向我显示以下日志:
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:20:32 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Cookie,Accept-Encoding
X-Frame-Options: SAMEORIGIN
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/javascript
GET /favicon.ico HTTP/1.1
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0.3) Gecko/51.0.3 Firefox/51.0.3
Host: ut3taavoni.ir
Accept-Encoding: gzip
If-Modified-Since: Wed, 22 Feb 2017 15:19:39 GMT
Cache-Control: max-age=60
Connection: keep-alive
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:20:34 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 0
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: image/vnd.microsoft.icon
Host: ut3taavoni.ir
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0) Gecko/51.0 Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/
Cookie: csrftoken=3yVd9UL6g69U6Chhy5MQqIcPAy9VyGUM; sessionid=d8xvyszgs05occnnac57lz0vd8zuvqy5
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------6169424391163634213177052432
Content-Length: 19033
Cache-Control: max-age=0
Connection: keep-alive
Content-Disposition: form-data; name="csrfmiddlewaretoken"
Content-Disposition: form-data; name="username"
Content-Disposition: form-data; name="first_name"
Content-Disposition: form-data; name="last_name"
Content-Disposition: form-data; name="email"
Content-Disposition: form-data; name="birth_date_0"
Content-Disposition: form-data; name="birth_date_1"
Content-Disposition: form-data; name="birth_date_2"
Content-Disposition: form-data; name="academic_degree"
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="academic_degr
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
POST /m3s/m3s-panel/members/user/501/ HTTP/1.1
Host: ut3taavoni.ir
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0) Gecko/51.0 Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/
Cookie: csrftoken=3yVd9UL6g69U6Chhy5MQqIcPAy9VyGUM; sessionid=d8xvyszgs05occnnac57lz0vd8zuvqy5
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------6169424391163634213177052432
Content-Length: 19033
Cache-Control: max-age=0
Connection: keep-alive
Content-Disposition: form-data; name="csrfmiddlewaretoken"
Content-Disposition: form-data; name="username"
Content-Disposition: form-data; name="first_name"
Content-Disposition: form-data; name="last_name"
Content-Disposition: form-data; name="email"
Content-Disposition: form-data; name="birth_date_0"
Content-Disposition: form-data; name="birth_date_1"
Content-Disposition: form-data; name="birth_date_2"
Content-Disposition: form-data; name="academic_degree"
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="academic_degr
Host: ut3taavoni.ir
User-Agent: jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)
Connection: close
POST /wp-cron.php?doing_wp_cron=1487776996.4416921138763427734375 HTTP/1.1
Host: ut3taavoni.ir
User-Agent: WordPress/4.7.2; http://ut3taavoni.ir
Accept: */*
Accept-Encoding: deflate, gzip
Referer: http://ut3taavoni.ir/wp-cron.php?doing_wp_cron=1487776996.4416921138763427734375
Connection: close
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:23:16 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adace494d41; expires=Wed, 22-Feb-2017 15:53:16 GMT; Max-Age=1800; path=/; HttpOnly
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:23:16 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adace4a1507; expires=Wed, 22-Feb-2017 15:53:16 GMT; Max-Age=1800; path=/; HttpOnly
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Link: <wp.me/P8gOjR-2>; rel=shortlink
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:24:55 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adad47d7d5c; expires=Wed, 22-Feb-2017 15:54:55 GMT; Max-Age=1800; path=/; HttpOnly
X-Robots-Tag: noindex, follow
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:24:55 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adad47e1c49; expires=Wed, 22-Feb-2017 15:54:55 GMT; Max-Age=1800; path=/; HttpOnly
X-Robots-Tag: noindex, follow
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
谢谢我亲爱的朋友阿米尔
我有一个 django 嵌套管理表单,下面的代码是我的 admin.py
文件内容:
# -*- coding:utf-8 -*-
from django.db.models import Q
from django import forms
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib import admin
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
from django.forms.utils import flatatt
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _, ugettext
from django.contrib.auth.models import Group, Permission
from nested_admin.nested import NestedStackedInline, NestedModelAdmin
from HomeMakers.apps.system.models import Dependant, Benefit, User, \
Unit, Stack, Parking
from mtools.fields import UniqueValueWidget, PersianDateField
class DependantAdminForm(forms.ModelForm):
model = Dependant
birth_date = PersianDateField(label=u'تاریخ تولد')
class DependantAdmin(NestedStackedInline):
model = Dependant
form = DependantAdminForm
extra = 0
exclude = ['changed_status', 'new_obj']
can_delete = True
class BenefitSubAdmin(admin.TabularInline):
model = Benefit
extra = 1
min_num = 0
exclude = ['changed_status', 'new_obj']
can_delete = True
class NewUserAdminForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = User
username = forms.RegexField(label=u"کد ملی", max_length=30, regex=r'^\d{8,10}$',
widget=UniqueValueWidget,
error_messages={'invalid': u"مقدار وارد شده قابل قبول نمیباشد."})
birth_date = PersianDateField(from_year=1290, to_year=1400, label=_('Birth Date'))
start_date = PersianDateField(from_year=1290, to_year=1400, label=u"تاریخ شروع به کار")
def clean_username(self):
# Since User.username is unique, this check is redundant,
# but it sets a nicer error message than the ORM. See #13147.
username = self.cleaned_data["username"]
if User.objects.filter(username=username).count() > 0:
raise forms.ValidationError(self.error_messages['duplicate_username'])
return username
class ReadOnlyPasswordHashWidget(forms.Widget):
def render(self, name, value, attrs):
encoded = value
final_attrs = self.build_attrs(attrs)
if not encoded or encoded.startswith(UNUSABLE_PASSWORD_PREFIX):
summary = mark_safe(u"<strong>%s</strong>" % _("No password set."))
else:
try:
hasher = identify_hasher(encoded)
except ValueError:
summary = mark_safe(u"<strong>%s</strong>" % _(
"Invalid password format or unknown hashing algorithm."))
else:
summary = u'''format_html_join('',
"<strong>{0}</strong>: {1} ",
((ugettext(key), value)
for key, value in hasher.safe_summary(encoded).items())
)'''
return format_html(u"<div{0}>{1}</div>", flatatt(final_attrs), summary)
class ReadOnlyPasswordHashField(forms.Field):
widget = ReadOnlyPasswordHashWidget
def __init__(self, *args, **kwargs):
kwargs.setdefault("required", False)
super(ReadOnlyPasswordHashField, self).__init__(*args, **kwargs)
def bound_data(self, data, initial):
# Always return initial because the widget doesn't
# render an input field.
return initial
def _has_changed(self, initial, data):
return False
class EditUserAdminForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = User
birth_date = PersianDateField(from_year=1290, to_year=1400, label=_('Birth Date'))
start_date = PersianDateField(from_year=1290, to_year=1400, label=u"تاریخ شروع به کار")
password = ReadOnlyPasswordHashField(label=_("Password"),
help_text=_("Raw passwords are not stored, so there is no way to see "
"this user's password, but you can change the password "
"using <a href=\"password/\">this form</a>."))
error_messages = {'duplicate_username': 'An user by this international code already exists.'}
def __init__(self, *args, **kwargs):
super(EditUserAdminForm, self).__init__(*args, **kwargs)
self.fields['username'] = forms.RegexField(label=u"کد ملی", max_length=30, regex=r'^\d{8,10}$',
widget=UniqueValueWidget(),
error_messages={'invalid': u"مقدار وارد شده قابل قبول نمیباشد."})
self.fields['username'].widget.attrs['value'] = self.instance.username
def clean_username(self):
# Since User.username is unique, this check is redundant,
# but it sets a nicer error message than the ORM. See #13147.
username = self.cleaned_data["username"]
if username != self.instance.username and User.objects.filter(username=username).count() > 0:
raise forms.ValidationError(self.error_messages['duplicate_username'])
return username
class UnitForm(forms.ModelForm):
model = Unit
installment_begin_date = PersianDateField(label=u'تاریخ شروع اقساط')
class StackSubAdmin(NestedStackedInline):
model = Stack
extra = 1
class ParkingSubAdmin(NestedStackedInline):
model = Parking
extra = 1
class UnitSubAdmin(NestedStackedInline): #(admin.StackedInline):
model = Unit
form = UnitForm
extra = 0
inlines = [ParkingSubAdmin, StackSubAdmin]
exclude = ['sum_of_pays', 'parkings', 'warehouse']
class UserAdmin(AuthUserAdmin, NestedModelAdmin):
model = User
ordering = ['last_name']
list_per_page = 10
add_form = NewUserAdminForm
form = EditUserAdminForm
list_display = ['user_thumb', 'first_name', 'last_name']
list_filter = ['units__project', 'groups']
formfield_overrides = {
# models.DateField: {'widget': PersianDateWidget}
}
'''fields = (
'username', 'password', 'first_name', 'last_name', 'email',
'gender', 'birth_date', 'picture', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'international_code', 'job_field', 'self_employed_job_name', 'employment_type',
'start_date', 'is_retired'
)'''
inlines = [DependantAdmin, UnitSubAdmin] # & BenefitSubAdmin
def get_fieldsets(self, request, obj=None):
key_fields = {'fields': ('username', 'password1', 'password2')}
if obj is not None:
key_fields = {'fields': ('username', 'password')}
fieldsets = (
(None, key_fields),
(u'اطلاعات تکمیلی', {'fields': (
'first_name', 'last_name', 'email',
'gender', 'birth_date', 'academic_degree', 'picture', 'international_card_scaned_file',
'certificate_scaned_file_page1', 'certificate_scaned_file_page2', 'academic_degree_scaned_file',
'job_edict_document', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'job_field', 'self_employed_job_name', 'employment_type', 'start_date',
'is_retired'
)}
),
(u'سطوح دسترسی', {'fields': ('is_active', 'is_staff', 'groups')})
# , 'user_permissions', 'is_superuser')}),
# (u'تاریخ های مهم', {'fields': ('last_login', 'date_joined')})
)
if request.user.is_superuser:
fieldsets = (
(None, key_fields),
(u'اطلاعات تکمیلی', {'fields': (
'first_name', 'last_name', 'email',
'gender', 'birth_date', 'academic_degree', 'picture', 'international_card_scaned_file',
'certificate_scaned_file_page1', 'certificate_scaned_file_page2', 'academic_degree_scaned_file',
'job_edict_document', 'certificate_no', 'birth_place', 'address', 'home_phone', 'work_phone',
'mobile', 'personnel_code', 'job_field', 'self_employed_job_name', 'employment_type', 'start_date',
'is_retired'
)}
),
(u'سطوح دسترسی', {'fields': (
'is_active',
'is_staff',
'is_superuser',
'user_permissions',
'groups'
)
})
# (u'تاریخ های مهم', {'fields': ('last_login', 'date_joined')})
)
return fieldsets
def get_queryset(self, request):
if request.user.is_superuser:
return User.objects.all()
return User.objects.filter(is_superuser=False)
class GroupAdmin(admin.ModelAdmin):
model = Group
filter_horizontal = ('permissions',)
def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "permissions" and not request.user.is_superuser:
kwargs["queryset"] = Permission.objects.exclude(
Q(codename__startswith='add_') |
Q(codename__startswith='change_') |
Q(codename__startswith='delete_')
)
return super(GroupAdmin, self).formfield_for_manytomany(
db_field,
request,
**kwargs
)
def save_model(self, request, group, form, change):
perms = []
for p in group.permissions.all():
if p.codename.startswith('add_') or \
p.codename.startswith('change_') or \
p.codename.startswith('delete_'):
perms.append(p)
super(GroupAdmin, self).save_model(request, group, form, change)
form.cleaned_data['permissions'] = list(
form.cleaned_data['permissions']
)
if not request.user.is_superuser:
form.cleaned_data['permissions'].extend(perms)
form.cleaned_data['permissions'] = list(set(
form.cleaned_data['permissions']))
group.save()
# register new user admin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.unregister(Group)
admin.site.register(Group, GroupAdmin)
当我在本地主机上开发和 运行 devserver 时,一切正常,但在服务器和域上,我无法通过 连接已重置 提交此表单信息。 下面的代码是我的 apache2 配置:
<VirtualHost *:80>
DocumentRoot "/var/www/wordpress"
# ServerName localhost
# Alias /wordpress /var/www/wordpress
# <Directory /var/www/wordpress>
# Options Indexes FollowSymLinks
# AllowOverride None
# Order Deny,Allow
# Allow from all
# </Directory>
WSGIScriptAlias /m3s /var/www/m3s/HomeMakers/wsgi.py
#ProxyPass /m3s/ http://127.0.0.1:8000/
#ProxyPassReverse /m3s/ http://127.0.0.1:8000/
#<Proxy http://127.0.0.1:8000/m3s/>
# Order Allow,Deny
# Allow from all
#</Proxy>
# WSGIDaemonProcess sentry python-path=/var/www/sentry/venv/lib/python2.7/site-packages
# WSGIScriptAlias /exceptions/tracker /var/www/sentry/venv/lib/python2.7/site-packages/sentry/wsgi.py
Alias /ufiles /var/www/m3s/media_files
Alias /static /var/www/m3s/sfiles
Alias /_static /var/www/sentry/venv/lib/python2.7/site-packages/sentry/static
Alias /mydb/admin /usr/share/phpmyadmin
<Directory "/var/www/m3s/HomeMakers/">
Options +ExecCGI
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/m3s/sfiles/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我也尝试同时使用 uwsgi 和 mod_proxy 但我的问题没有解决。在我通过 access.log 和我的服务器端口 80 监控 tshark 之后,tshard 向我显示了这个请求,但是在 access.log 文件我看不到任何变化...
Apache 以信息模式登录:
[Sun Jan 29 21:15:47.896062 2017] [wsgi:warn] [pid 7596] mod_wsgi: Compiled for Python/2.7.11.
[Sun Jan 29 21:15:47.896100 2017] [wsgi:warn] [pid 7596] mod_wsgi: Runtime using Python/2.7.11+.
[Sun Jan 29 21:15:47.898887 2017] [mpm_prefork:notice] [pid 7596] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.11+ configured -- resuming normal operations
[Sun Jan 29 21:15:47.898913 2017] [core:notice] [pid 7596] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jan 29 21:16:43.833245 2017] [wsgi:info] [pid 7599] [client 84.241.62.118:44316] mod_wsgi (pid=7599, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'.
[Sun Jan 29 21:16:45.317557 2017] [wsgi:error] [pid 7599] DEBUG 2017-01-29 21:16:45,317 base 7599 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a12c>
[Sun Jan 29 21:16:47.484799 2017] [wsgi:info] [pid 7602] [client 84.241.62.118:42751] mod_wsgi (pid=7602, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'., referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619
[Sun Jan 29 21:16:48.899865 2017] [wsgi:error] [pid 7602] DEBUG 2017-01-29 21:16:48,899 base 7602 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a12c>
[Sun Jan 29 21:17:33.961983 2017] [wsgi:info] [pid 7603] [client 84.241.62.118:20515] mod_wsgi (pid=7603, process='', application='ut3taavoni.ir|/m3s'): Loading WSGI script '/var/www/m3s/HomeMakers/wsgi.py'., referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619
[Sun Jan 29 21:17:35.360116 2017] [wsgi:error] [pid 7603] DEBUG 2017-01-29 21:17:35,360 base 7603 -1220638144 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0xada5a1ac>
还有我的access.log文件内容:
192.0.102.40 - - [29/Jan/2017:22:37:30 +0330] "HEAD / HTTP/1.1" 200 372 "-" "jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)"
xxx.241.62.118 - - [29/Jan/2017:22:37:56 +0330] "GET /m3s/m3s-panel/members/user/ HTTP/1.1" 200 4627 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:37:57 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:51 +0330] "GET /m3s/m3s-panel/members/user/?q=0065231619 HTTP/1.1" 200 4195 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:51 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/?q=0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:54 +0330] "GET /m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619 HTTP/1.1" 200 14967 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/?q=0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:55 +0330] "GET /m3s/m3s-panel/jsi18n/ HTTP/1.1" 200 10588 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
xxx.241.62.118 - - [29/Jan/2017:22:38:55 +0330] "GET /m3s/_nested_admin/server-data.js HTTP/1.1" 200 388 "http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/?_changelist_filters=q%3D0065231619" "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
我在 ServerFault 站点上的相关问题: https://serverfault.com/questions/827813/apache-respons-to-get-but-not-to-post
更新:
我再次 运行 tshark 并看到下面 important 行:
7 0.754812317 5.113.18.90 -> xxx.156.28.145 HTTP 1434 POST /m3s/m3s-panel/members/user/501/ HTTP/1.1 [Malformed Packet]
下面是我的浏览器"Request Payload":
Content-Type: multipart/form-data; boundary=---------------------------51995842320268179811054389612
Content-Length: 4614
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="csrfmiddlewaretoken"
STMAQ1bSTuWsl9CelQBK5S2QjUKIfZ1Z
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="username"
9265291619
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="first_name"
اعظم
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="last_name"
جعفری
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="email"
jafariphd@ut.ac.ir
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="gender"
0
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_0"
15
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_1"
6
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_date_2"
1356
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="academic_degree"
5
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="academic_degree_scaned_file"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="job_edict_document"; filename=""
Content-Type: application/octet-stream
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="certificate_no"
11909
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="birth_place"
تهران
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="address"
تهران -میدان پاستور-خ پاستور غربی-خ آژیده-کوچه آفین-پ 7-طبقه اول غربی
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="home_phone"
66915902
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="work_phone"
66409696
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="mobile"
09125114282
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="personnel_code"
26687
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="job_field"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="self_employed_job_name"
کارشناس معماری
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="employment_type"
3
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_0"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_1"
1
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="start_date_2"
1385
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="is_active"
on
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="is_staff"
on
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="groups"
3
-----------------------------51995842320268179811054389612
Content-Disposition: form-data; name="_continue"
ذخیره و ادامهٔ ویرایش
-----------------------------51995842320268179811054389612--
但现在我的问题是这个问题是如何发生的,我该如何解决?
我们在 Cent OS 64 位 Apache 2.4 的新安装系统上遇到了同样的问题。 Apache 有时会断开连接,它落后于 nginx,所以我们经常遇到 502 网关错误。日志中没有任何内容,没有启用调试,没有崩溃转储等等。
解决问题的唯一解决方案 - rebuild/reinstall Apache 完全。我们在将调试输出代码添加到 Apache 源并重建时找到了这个解决方案,想知道我们的调试代码如何解决问题。但它只是 re-build.
P.S。还要仔细遵循有关调试 WSGI http://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html
的建议我允许我的朋友访问我的 VPS,然后他告诉我我的问题与 wordpress 有关,并在页面加载并按下提交后向我显示以下日志:
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:20:32 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Cookie,Accept-Encoding
X-Frame-Options: SAMEORIGIN
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/javascript
GET /favicon.ico HTTP/1.1
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0.3) Gecko/51.0.3 Firefox/51.0.3
Host: ut3taavoni.ir
Accept-Encoding: gzip
If-Modified-Since: Wed, 22 Feb 2017 15:19:39 GMT
Cache-Control: max-age=60
Connection: keep-alive
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:20:34 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 0
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: image/vnd.microsoft.icon
Host: ut3taavoni.ir
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0) Gecko/51.0 Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/
Cookie: csrftoken=3yVd9UL6g69U6Chhy5MQqIcPAy9VyGUM; sessionid=d8xvyszgs05occnnac57lz0vd8zuvqy5
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------6169424391163634213177052432
Content-Length: 19033
Cache-Control: max-age=0
Connection: keep-alive
Content-Disposition: form-data; name="csrfmiddlewaretoken"
Content-Disposition: form-data; name="username"
Content-Disposition: form-data; name="first_name"
Content-Disposition: form-data; name="last_name"
Content-Disposition: form-data; name="email"
Content-Disposition: form-data; name="birth_date_0"
Content-Disposition: form-data; name="birth_date_1"
Content-Disposition: form-data; name="birth_date_2"
Content-Disposition: form-data; name="academic_degree"
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="academic_degr
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:16:32 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
POST /m3s/m3s-panel/members/user/501/ HTTP/1.1
Host: ut3taavoni.ir
User-Agent: Mozilla/5.0 (Android 6.0.1; Mobile; rv:51.0) Gecko/51.0 Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://ut3taavoni.ir/m3s/m3s-panel/members/user/501/
Cookie: csrftoken=3yVd9UL6g69U6Chhy5MQqIcPAy9VyGUM; sessionid=d8xvyszgs05occnnac57lz0vd8zuvqy5
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=---------------------------6169424391163634213177052432
Content-Length: 19033
Cache-Control: max-age=0
Connection: keep-alive
Content-Disposition: form-data; name="csrfmiddlewaretoken"
Content-Disposition: form-data; name="username"
Content-Disposition: form-data; name="first_name"
Content-Disposition: form-data; name="last_name"
Content-Disposition: form-data; name="email"
Content-Disposition: form-data; name="birth_date_0"
Content-Disposition: form-data; name="birth_date_1"
Content-Disposition: form-data; name="birth_date_2"
Content-Disposition: form-data; name="academic_degree"
Content-Disposition: form-data; name="picture"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="international_card_scaned_file"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page1"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="certificate_scaned_file_page2"; filename=""
Content-Type: application/octet-stream
Content-Disposition: form-data; name="academic_degr
Host: ut3taavoni.ir
User-Agent: jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)
Connection: close
POST /wp-cron.php?doing_wp_cron=1487776996.4416921138763427734375 HTTP/1.1
Host: ut3taavoni.ir
User-Agent: WordPress/4.7.2; http://ut3taavoni.ir
Accept: */*
Accept-Encoding: deflate, gzip
Referer: http://ut3taavoni.ir/wp-cron.php?doing_wp_cron=1487776996.4416921138763427734375
Connection: close
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
HTTP/1.1 200 OK
Date: Wed, 22 Feb 2017 15:23:16 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adace494d41; expires=Wed, 22-Feb-2017 15:53:16 GMT; Max-Age=1800; path=/; HttpOnly
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:23:16 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adace4a1507; expires=Wed, 22-Feb-2017 15:53:16 GMT; Max-Age=1800; path=/; HttpOnly
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Link: <wp.me/P8gOjR-2>; rel=shortlink
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:18:20 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:24:55 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adad47d7d5c; expires=Wed, 22-Feb-2017 15:54:55 GMT; Max-Age=1800; path=/; HttpOnly
X-Robots-Tag: noindex, follow
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:24:55 GMT
Server: Apache/2.4.18 (Ubuntu)
Set-Cookie: wfvt_2147194919=58adad47e1c49; expires=Wed, 22-Feb-2017 15:54:55 GMT; Max-Age=1800; path=/; HttpOnly
X-Robots-Tag: noindex, follow
Link: <http://ut3taavoni.ir/wp-json/>; rel="https://api.w.org/"
Connection: close
Content-Type: text/html; charset=UTF-8
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:19:58 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
Date: Wed, 22 Feb 2017 15:20:45 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: text/html
谢谢我亲爱的朋友阿米尔