Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have my application running at the second level domain (say, example.com). Here is the file located in sites-enabled:

upstream unicorn {
  server unix:/tmp/unicorn.appname.sock fail_timeout=0;
}

server {
  server_name example.com, www.example.com;
  listen 00.000.000.000;
  root /home/deployer/apps/appname/current/public;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control 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;
  client_max_body_size 4G;
  keepalive_timeout 10;

}

It works fine.
Now I'd like to move application to admin.example.com/applicationname

Can I simply change server_name to admin.example.com/applicationname, or it should be accomplished in a different way?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Now I'd like to move application to admin.example.com/applicationname

For sake of clarity — From where?

Can I simply change server_name to admin.example.com/applicationname, or it should be accomplished in a different way?

You can, but it simply won't work — server name should contain only domain part of URI.

I can assume that what you're really asking about is moving application from "/" to "/subfolder", and in that case there's special part of documentation for you: «…

If proxy_pass is specified with URI, when passing a request to the server, part of a normalized request URI matching the location is replaced by a URI specified in the directive:

location /name/ {
proxy_pass http://127.0.0.1/remote/;
}

…»

share|improve this answer
    
Thank you! That's exactly what I was looking for. –  Ivan Zamylin Apr 8 '13 at 16:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.