Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 Internal error with Apache #6350

Closed
guoyunhe opened this issue May 6, 2017 · 3 comments
Closed

500 Internal error with Apache #6350

guoyunhe opened this issue May 6, 2017 · 3 comments
Labels

Comments

@guoyunhe
Copy link

guoyunhe commented May 6, 2017

Pootle 2.8.0rc5 (Django 1.10.7, Translate Toolkit 2.0.0)

I have installed Pootle following instruction. I can run it with

pootle runserver --insecure

But when I switch to Apache (wsgi, not proxy), it throw 500 error. In apache error log, I found:

[Sat May 06 13:15:56.827925 2017] [wsgi:error] [pid 11006] [client 84.249.204.100:45130] Truncated or oversized response headers received from daemon process 'pootle': /srv/www/vhosts/pootle/wsgi.py
[Sat May 06 13:15:56.863319 2017] [core:notice] [pid 10996] AH00052: child pid 11446 exit signal Segmentation fault (11)

But I have no idea what happened.

pootle.conf

<VirtualHost *:80>
    # Domain for the Pootle server. Use 'localhost' for local deployments.
    #
    # If you want to deploy on example.com/your-pootle/ rather than in
    # my-pootle.example.com/ you will have to do the following changes to
    # this sample Apache configuration:
    #
    # - Change the ServerName directive to:
    #   ServerName example.com
    # - Change the WSGIScriptAlias directive to (note that /your-pootle must
    #   not end with a slash):
    #   WSGIScriptAlias /your-pootle /srv/www/vhosts/pootle/wsgi.py
    # - Change the Alias directive for 'assets' to include the '/your-pootle'.
    # - Include the following settings in your custom Pootle settings:
    #   STATIC_URL = '/your-pootle/assets/'
    #   FORCE_SCRIPT_NAME = '/your-pootle'
    # - If you have previously calculated the stats:
    #   - Restart the RQ workers.
    #   - Run refresh_stats to recalculate the stats data.
    ServerName translate.kde-china.org

    # Set the 'POOTLE_SETTINGS' environment variable pointing at your custom
    # Pootle settings file.
    #
    # If you don't know which settings to include in this file you can use
    # the file '90-local.conf.sample' as a starting point. This file can be
    # found at '/srv/www/vhosts/pootle/env/lib/python2.7/site-packages/pootle/settings/'.
    #
    # Another way to specify your custom settings is to comment this
    # directive and add a new '90-local.conf' file (by copying the file
    # '90-local.conf.sample' and changing the desired settings) in
    # '/srv/www/vhosts/pootle/env/lib/python2.7/site-packages/pootle/settings/'
    # (default location for a pip-installed Pootle, having Python 2.7).
    #
    # This might require enabling the 'env' module.
    SetEnv POOTLE_SETTINGS /srv/www/vhosts/pootle/pootle.conf


    # The following two optional lines enable the "daemon mode" which
    # limits the number of processes and therefore also keeps memory use
    # more predictable.
    WSGIDaemonProcess pootle processes=2 threads=3 stack-size=1048576 maximum-requests=500 inactivity-timeout=300 display-name=%{GROUP} python-path=/srv/www/vhosts/pootle/env/lib/python2.7/site-packages
    WSGIProcessGroup pootle

    WSGIApplicationGroup {GLOBAL}

    # Point to the WSGI loader script.
    WSGIScriptAlias / /srv/www/vhosts/pootle/wsgi.py
    <Directory /srv/www/vhosts/pootle>
        Order deny,allow
        Allow from all
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    # Turn off directory listing by default.
    Options -Indexes

    # Compress before being sent to the client over the network.
    # This might require enabling the 'deflate' module.
    SetOutputFilter DEFLATE
    AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript

    # Set expiration for some types of files.
    # This might require enabling the 'expires' module.
    ExpiresActive On

    ExpiresByType image/jpg "access plus 10 years"
    ExpiresByType image/png "access plus 10 years"
    ExpiresByType text/css "access plus 10 years"
    ExpiresByType application/x-javascript "access plus 10 years"

    # Optimal caching by proxies.
    # This might require enabling the 'headers' module.
    Header set Cache-Control "public"

    # Directly serve static files like css and images, no need to go
    # through mod_wsgi and Django. For high performance consider having a
    # separate server.
    Alias /assets /srv/www/vhosts/pootle/env/lib/python2.7/site-packages/pootle/assets
    <Directory /srv/www/vhosts/pootle/env/lib/python2.7/site-packages/pootle/assets>
        Order deny,allow
        Allow from all
    </Directory>

</VirtualHost>

wsgi.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import site
import sys


# You probably will need to change these paths to match your deployment,
# most likely because of the Python version you are using.
ALLDIRS = [
    '/srv/www/vhosts/pootle/env/lib/python2.7/site-packages',
    '/srv/www/vhosts/pootle/env/lib/python2.7/site-packages/pootle/apps',
]

# Remember original sys.path.
prev_sys_path = list(sys.path)

# Add each new site-packages directory.
for directory in ALLDIRS:
    site.addsitedir(directory)

# Reorder sys.path so new directories at the front.
new_sys_path = []

for item in list(sys.path):
    if item not in prev_sys_path:
        new_sys_path.append(item)
        sys.path.remove(item)

sys.path[:0] = new_sys_path

# Set the Pootle settings module as DJANGO_SETTINGS_MODULE.
os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'


# Set the WSGI application.
def application(environ, start_response):
    """Wrapper for Django's WSGIHandler().

    This allows to get values specified by SetEnv in the Apache
    configuration or interpose other changes to that environment, like
    installing middleware.
    """
    try:
        os.environ['POOTLE_SETTINGS'] = environ['POOTLE_SETTINGS']
    except KeyError:
        pass

    from django.core.wsgi import get_wsgi_application
    _wsgi_application = get_wsgi_application()
    return _wsgi_application(environ, start_response)
@dwaynebailey
Copy link
Member

@guoyunhe is this not a missing ALLOWED_HOSTS setting?

@unho unho added the question label Jun 8, 2017
@phlax
Copy link
Member

phlax commented Jun 8, 2017

could also be related to a uwsgi setting related to headers

i need to find a ref...

@dwaynebailey
Copy link
Member

We're pretty certain this solved with ALLOWED_HOSTS, but without feedback we can't confirm. So closing for now, please open if this issue is not solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants