# Generals Subfolder recommendations and tips

**URL:** <https://meta.discourse.org/t/generals-subfolder-recommendations-and-tips/74401>\
**Category:** Self-hosting\
**Created:** [20 Settembre 2016, 9:39pm UTC](https://meta.discourse.org/t/generals-subfolder-recommendations-and-tips/74401 "2016-09-20T21:39:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jmg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jmg/32/121440_2.png) [@jmg](https://meta.discourse.org/u/jmg)\
**Post date:** [26 Settembre 2016, 9:05am UTC](https://meta.discourse.org/t/generals-subfolder-recommendations-and-tips/74401/2 "2016-09-26T09:05:13Z")

</div>

And an Nginx example (file _/etc/nginx/sites-available/example.com_) that seems to be working well for Discourse subfolder (/forum), WordPress site on the same server (root), and _https_ (with SSL/TLS), including permanent redirections _http → https_, and _www. → non-www._:

```
server {
  listen 127.0.0.10:80;
  server_name www.example.com;
  return 301 https://example.com$request_uri;
}

server {
  listen 127.0.0.10:443 ssl;
  server_name www.example.com;
  ssl_certificate /srv/www/example/ssl.cert;
  ssl_certificate_key /srv/www/example/ssl.key;
  return 301 https://example.com$request_uri;
}

server {
  listen 127.0.0.10:80 default_server;
  server_name example.com;
  return 301 https://example.com$request_uri;
}

server {
  listen 127.0.0.10:443 default_server ssl;
  server_name example.com;
  ssl_certificate /srv/www/example/ssl.cert;
  ssl_certificate_key /srv/www/example/ssl.key;

  # Configuration for the Discourse subfolder /forum
  location /forum/ {
    proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  # Configuration for the rest of the site (WordPress)
  location / {
    root /srv/www/example/public_html;
    index index.html index.htm index.php;
    access_log /var/log/virtualmin/example.com_access_log;
    error_log /var/log/virtualmin/example.com_error_log;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME /srv/www/example/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /srv/www/example/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param HTTPS $https;
    include /srv/www/example/public_html/nginx.conf;
    location ~ \.php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/php-nginx/147000774813312.sock/socket;
    }
    if (!-e $request_filename) {
      rewrite ^.*$ /index.php last;
    }
    fastcgi_read_timeout 60;
  }
}

```

---

_[View the full topic](https://meta.discourse.org/t/generals-subfolder-recommendations-and-tips/74401)._
