What might cause "<ProtocolError for 127.0.0.1:80/cobbler_api: 301 Moved Permanently>"
by Crawford, Mike (Helion Eucalyptus)
I could not find any solutions to this problem in Google, hope this isn’t considered spam.
I’m new to Cobbler and Django, not sure what’s going on. I want to run cobbler on a virtual host along with other virtual hosts on the same server. I have an existing software mirror which matches the directory structure of mirrors.kernel.org, for example, which I want to use. On two Vms I have created to test cobbler, I can install cobbler and see it working off the IP address of the host, then I add in a virtual host to run it, and I can see it working there. I’m able to use the CLI to add distributions which point to my existing mirror structure (I.e. /var/lib/mirror/centos/6.7/os/x86_64). Thought all was fine. I was about to switch over to using this instead of the hand-rolled PXE/Kickstart method I’d been using before.
Then, for no change I can remember making, access to the cobbler website or use of the CLI starts returning "<ProtocolError for 127.0.0.1:80/cobbler_api: 301 Moved Permanently>”, or this changes to "<ProtocolError for 192.168.40.76:80/cobbler_api: 301 Moved Permanently>”, which is the IP address of the VM where I’m running this. I get this traceback:
——————————
Environment:
Request Method: GET
Request URL: https://192.168.40.76/cobbler_web/
Django Version: 1.6.11
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'cobbler_web')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/share/cobbler/web/cobbler_web/views.py" in index
58. if not test_user_authenticated(request): return login(request,next="/cobbler_web", expired=True)
File "/usr/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/share/cobbler/web/cobbler_web/views.py" in login
1284. token = remote.login("", utils.get_shared_secret())
File "/usr/lib64/python2.7/xmlrpclib.py" in __call__
1224. return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py" in __request
1578. verbose=self.__verbose
File "/usr/lib64/python2.7/xmlrpclib.py" in request
1264. return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python2.7/xmlrpclib.py" in single_request
1312. response.msg,
Exception Type: ProtocolError at /
Exception Value: <ProtocolError for 192.168.40.76:80/cobbler_api: 301 Moved Permanently>
——————————
This has now happened on two different virtual machines where I’m attempting to test this, where it worked for a while, then started to throw this error. No indication as to why, and I don’t know Django enough to know where to look for what might be needed to correct this.
Here’s what I did to set this up, basically going off this URL: http://www.olindata.com/blog/2015/07/cobbler-setup-centos7
1. Created new CentOS 7 VM inside VMware Fusion on Mac running OS X Yosemite, minimal install.
2. yum install cobbler cobbler-web dnsmasq syslinux pykickstart
3. This creates /etc/httpd/conf.d/cobbler.conf and /etc/httpd/conf.d/cobbler_web.conf files which I haven’t modified
4. I start cobblerd and httpd
5. I can run cobbler CLI commands and view the website on https://192.168.40.76/cobbler_web/
6. I modify /etc/httpd/conf/httpd.conf to add an include of /etc/httpd/conf.vhosts.d/ where I put per-vhost configuration files.
7. I create a vhost file for the separate cobbler vhost: /etc/httpd/conf.vhosts.d/cobbler.example.com.conf (contents below)
8. I create an entry in /etc/hosts: 192.168.40.76 cobbler.example.com
9. I’m able to log into the new http://cobbler.example.com site, and this redirects to https://cobbler.example.com/cobbler_web/ as expected, and I can see and manage cobbler, same as with the IP-based site.
10. At some point after this works, it just stops working and throws the error noted above. This has now happened on two separate macs with similar VMware Fusion environments. One is an iMac and has pretty static networking, the other a MBP which moves. This results in changes to the MBP’s main IP address, but the VM is on the NAT network with a stable IP of 192.168.40.76.
Here’s the virtual host configuration file /etc/httpd/conf.vhosts.d/cobbler.example.com.conf:
#
# Example Company Cobbler
#
<VirtualHost *:80>
ServerName cobbler.example.com
ServerAlias cobbler01.example.com
ServerAdmin webmaster(a)example.com
RewriteEngine On
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
CustomLog /var/log/httpd/cobbler.example.com-access.log combined
ErrorLog /var/log/httpd/cobbler.example.com-error.log
LogLevel warn
</VirtualHost>
<VirtualHost *:443>
ServerName cobbler.example.com
ServerAlias cobbler01.example.com
ServerAdmin webmaster(a)example.com
RewriteEngine On
RewriteRule ^$ /cobbler_web/ [R=301,L]
RewriteRule ^/$ /cobbler_web/ [R=301,L]
CustomLog /var/log/httpd/cobbler.example.com-access.log combined
ErrorLog /var/log/httpd/cobbler.example.com-error.log
LogLevel warn
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/pki/tls/certs/star.example.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/star.example.com.key
SSLCertificateChainFile /etc/pki/tls/certs/star.example.com.crt
</VirtualHost>
Any idea what could be going on?
Thanks in advance!
Mike