> For the complete documentation index, see [llms.txt](https://commandbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://commandbox.ortusbooks.com/5.3.0/embedded-server/external-web-server.md).

# External Web Server

You can place CommandBox downstream behind another external web server if you wish. Here is an overview of how to do that.

## Microsoft IIS

## Apache HTTP

## Nginx

```
server {

  server_name  example.net www.example.net;

  root /app;

  index index.cfm index.html index.htm;

  proxy_redirect           off;
  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_set_header         X-Forwarded-Proto $scheme;

  location ~ /WEB-INF/  { access_log off; log_not_found off; deny all; }
  location ~ /META-INF/  { access_log off; log_not_found off; deny all; }
  location ~ /META-INF/ { return 404; }
  location ~ /WEB-INF/ { return 404; }
  location ~ \.config$ { return 404; }
  location ~ /\. { return 404; } ## e.g. .htaccess, .gitignore etc.
  location ~ ~$ { return 404; }
  location ~ \.aspx?$ { return 404; } ## most likely hackers testing the site
  location ~ \.php$ { return 404; } 

  # this prevents hidden files (beginning with a period) from being served
  location ~ /\. {
    access_log off; log_not_found off; deny all;
  }

  # Do not log missing favicon.ico errors
  location ^/(favicon\.ico|apple-touch-icon.*\.png)$ { 
    access_log off; log_not_found off; 
  } 
  location = /robots.txt  { 
    access_log off; log_not_found off; 
  }

  location / {
    try_files $uri $uri/ @rewrites;
  }

  #set indexfileinurls=0 in Mura's settings.ini.cfm     
  location @rewrites {
    rewrite ^/(.*)? /index.cfm/$1 last;
    rewrite ^ /index.cfm last;
  }

  # Main Railo/Lucee proxy handler
  location ~ \.(cfm|cfml|cfc|jsp|cfr)(.*)$ {
    proxy_pass http://127.0.0.1:8080;
  }

  # Some basic cache-control for static files to be sent to the browser
  location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm|js|css)$ {
    expires 1M;
    #expires modified +90d;
    access_log off;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  }

  listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
  listen 443 ssl http2; # managed by Certbot
  ssl_certificate /etc/letsencrypt/live/example.net/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/example.net/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {

  if ($host ~ ^[^.]+\.example\.net$) {
      return 301 https://$host$request_uri;
  } # managed by Certbot

  if ($host = example.net) {
      return 301 https://$host$request_uri;
  } # managed by Certbot


  listen 80;
  listen [::]:80;
  server_name  example.net www.example.net;
  return 404; # managed by Certbot

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://commandbox.ortusbooks.com/5.3.0/embedded-server/external-web-server.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
