This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We're still getting "The change you wanted was rejected" errors when we try to submit a form. This is because Nginx isn't forwarding all the headers in the requests it receives to Unicorn. Let's fix that now, in addition to setting a few more important configuration items.
The new Nginx configuration items shown in this video were copied from the Unicorn project's sample Nginx configuration.
Our final config/nginx.conf
contents:
upstream unicorn {
server unix:/tmp/unicorn.guestbook.sock fail_timeout=0;
}
server {
client_max_body_size 4G;
listen 80 default;
root /home/deploy/guestbook/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
}
Our final config/unicorn.rb
contents:
pid "/home/deploy/guestbook/pids/unicorn.pid"
stderr_path "/home/deploy/guestbook/unicorn/unicorn.log"
stdout_path "/home/deploy/guestbook/unicorn/unicorn.log"
listen "/tmp/unicorn.guestbook.sock"
worker_processes 2
timeout 30
Be sure to run sudo service nginx restart
after updating nginx.conf
. Once you do, you should be able to visit your app and submit forms.
Further Reading
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up