How can I configure two droplets using nginx proxy_pass?

December 1, 2013 3.2k views
I'm having a lot of trouble understanding how nginx deals with proxy_pass and, after hours of breaking things, it seems that I can't do what I want. I have two servers with different IP. One will serve a python application, and the other, a WordPress website. The first server answers all the requests to, so the configuration looks like this: ``` server { listen 80; server_name *; return 301 $scheme://$request_uri; } server { listen 80; server_name; location / { try_files $uri @application; } location @application { include uwsgi_params; uwsgi_pass; } location /preview/wordpress { proxy_pass $scheme://; proxy_set_header Host $host; } } ``` Everything looks and works just fine. The only question I have here is what is the difference between proxy_pass $scheme://; and proxy_pass $scheme://; with the trailing slash? The other server should answer requests from The configuration looks like this: ``` server { listen 80; server_name; root /srv/www/; index index.php; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /preview/wordpress { alias /srv/www/; try_files $uri $uri/ /preview/wordpress/index.php?$args; } location ~ \.php$ { include fastcgi_params; fastcgi_split_path_info ^(/preview/wordpress)(/.*)$; fastcgi_intercept_errors on; fastcgi_pass unix:/var/run/php5-fpm.sock; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } } ``` I'm pretty sure that the error is in this configuration file. I don't know what location blocks should I use to handle the requests made by the other server. I really appreciate if anyone can give me an 101 class about nginx proxy_pass
2 Answers
Try replacing $scheme with http, restart nginx, does it work? If not, what do you see when you try to browse to /preview/wordpress?
The http change doesn't solve anything. The main server is working completely fine, when you go to /preview/wordpress it pass the request to the other server. I'm having problems handling the passed requests at the second server. Sometimes it shows me a forbidden error or a 404 error.

Let me ask this differently. How can I setup one server to answer the requests at and, if and only if the user opens, show a WordPress blog stored in the other server?
Have another answer? Share your knowledge.