title: Nginx Subdomains: Redirect /.well-known path for Let's Encrypt
body: <p>I have an Nginx Server running with two sub-domains. One of them uses a proxy_pass to redirect everything to a Meteor Application and the other sub-domain just uses Laravel but in a diffrent directory than the normal domain.</p>
  
  <p>So, when I start <code>./letsencrypt-auto</code> I get the following error-message for both sub-domains:</p>
  
  <pre><code>Failed authorization procedure. subdomain.mydomain.com (http-01): urn:acme:error:unauthorized ::
  The client lacks sufficient authorization :: Invalid response from http://subdomain.mydomain.com/.well-known/acme-challenge/xyzxyzxy_xzyzxyxyyx_xyzyxzyxz: "&lt;html&gt;
  &lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;
  &lt;body bgcolor="white"&gt;
  &lt;center&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/center&gt;
  </code></pre>
  
  <p>My interpretation of that is, that it doesn't work because my Laravel-Subdomain is not in <code>/var/www/domain.com/html</code> but in <code>/var/www/laravel/html</code> and my Meteor-Application is somwhere else and ngnix just does the proxy passing.</p>
  
  <p><strong>So my question is:</strong> Can I redirect <code>/.well-known/acme-challenge</code> for both subdomains to the real /.well-known so that letsencrypt-auto doesn't throw this error?</p>
  
  <hr>
  
  <h2>More Information:</h2>
  
  <p>I've tried</p>
  
  <pre><code>location '/.well-known/acme-challenge' {
      default_type "text/plain";
      root /tmp/letsencrypt-auto;
  }
  </code></pre>
  
  <p>but it didn't work...</p>
  
  <p>Config for my Meteor sub-domain:</p>
  
  <pre><code>server {
          listen 80;
          listen [::]:80;
  
          # SSL configuration
          listen 443 ssl;
          listen [::]:443 ssl;
  
          ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
  
          […] SSL stuff […]
  
  
          server_name meteor.domain.com;
  
          location / {
          proxy_pass http://localhost:3000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header X-Forwarded-For $remote_addr;
          }
  
          location ~ /.well-known {
                  allow all;
          }
  
  }
  </code></pre>
  
  <p>Config for my Laravel sub-domain:</p>
  
  <pre><code>server {
          listen 80;
          server_name laravel.domain.com;
  
          listen 443 ssl;
          listen [::]:443 ssl;
  
          ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
  
          […] SSL stuff […]
  
          root /var/www/laravel/html;
  
  
          location / {
                  try_files $uri $uri/ /index.php$is_args$args;
          }
  
      location ~ /.well-known {
                  allow all;
          }
  
      location ~ \.(hh|php)$ {
          fastcgi_keep_conn on;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include        fastcgi_params;
      }
  }    
  </code></pre>