Report this

What is the reason for this report?

Multiple Subdomains using Nginx and Ubuntu 14

Posted on February 15, 2015

All,

I am really hoping someone can help me out here. I have looked at many other posts with the same issue, but have yet to reach success.

I am trying to set up a second subdomain on the same Ubuntu droplet, but every time I access it, I get 302 redirected to the first one.

I have DNS set for both comicwars and comicwarsconsoleapi as A records pointing to my DO droplet at 104.236.110.172. I have the comicwarsconsoleapi subdomain set as a proxy pass-through to a local listener on port 1337. I want my comicwars subdomain to point to a website at /var/www/comicwarsweb. I also set chown on /var/www/comicwarsweb to www-data -R and have set the same folder to chmod 755 My /etc/nginx/sites-enabled/default configuration is as follows and have run sudo service nginx reload and sudo service nginx restart to no effect:

server {
	listen 80;
	server_name comicwars.jaxmeier.org;
	
	access_log /var/log/nginx/comicwars-access.log;
	error_log /var/log/nginx/comicwars-error.log debug;

	root	/var/www/comicwarsweb;
	index	index.html;

	location / {
        	proxy_set_header  X-Real-IP               $remote_addr;
                proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_set_header Host                        $http_host;
                proxy_redirect false;
	}
}

server {

	listen 80;
	server_name comicwarsapiconsole.jaxmeier.org;

	access_log /var/log/nginx/comicwarsapiconsole-access.log;
	error_log /var/log/nginx/comicwarsapiconsole-error.log debug;

	location / {
		proxy_pass 	    http://localhost:1337/;
                proxy_set_header    Host                       $host:1337;
            	proxy_set_header    X-Real-IP               $remote_addr;
         	proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
          	proxy_set_header    X-Client-Verify      SUCCESS;
          	proxy_set_header    X-Client-DN           $ssl_client_s_dn;
          	proxy_set_header    X-SSL-Subject       $ssl_client_s_dn;
          	proxy_set_header    X-SSL-Issuer         $ssl_client_i_dn;

	}
}


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Nevermind. I think there was an error in my config file that was preventing nginx from reloading. Once I made the change and nginx reloaded, all worked as expected.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.