Troubleshooting Application Access
This page describes common issues that you might encounter in managing access to applications with Teleport and how to work around or resolve them.
Unable to access applications
The most common issues that prevent access to applications involve Cross-Site Request Forgery (CSRF) or Cross-Origin Resource Sharing (CORS) errors.
Cross-Site Request Forgery is a type of attack that uses an authenticated user's identity to perform operations without the user's knowledge. For example, a CSRF attack might transfer funds, change passwords, or make purchases by issuing a forged request with the user's credentials. Browsers and applications have checks to prevent these types of attacks. However, the checks can also block legitimate requests under certain conditions.
Symptom
If your browser can't create a secure cookie or can't authorize your login from a previously-created secure cookie, you might see the following error:
Invalid or missing CSRF token
This error can be caused by ad-blocking or script-blocking extensions or by the browser itself. For access to applications through Teleport, you might see this error with most often with applications—like Grafana and ArgoCD—that use WebSockets extensively and in browsers where cross-site scripting restrictions require traffic to be explicitly allowed.
Issues with Cross-Site Request Forgery (CSRF) or Cross-Origin Resource Sharing (CORS) usually result in a loss of application functionality, errors in the application itself indicating that traffic isn't being permitted, or application logs that indicate CORS or CSRF errors.
In most cases, you can fix these types of issues by adding explicit rewrite settings for the Origin and Host headers
in the Teleport configuration for each application.
Solution 1: Application Service configuration file
To fix CSRF or CORS issues if you use statically configured apps in /etc/teleport.yaml:
- Open the
/etc/teleport.yamlfile that contains the application configuration in a text editor.
- Add a
rewrite.headerssection similar to the followinggrafanaexample:
app_service:
enabled: true
apps:
- name: grafana
uri: http://localhost:3000
public_addr: grafana.teleport.example.com
rewrite:
headers:
- "Origin: https://grafana.teleport.example.com" # Teleport application subdomain prepended with "https://"
- "Host: grafana.teleport.example.com" # Teleport application subdomain itself
- Save your changes and restart the Teleport service.
Solution 2: teleport-kube-agent values file
To fix CSRF or CORS issues if you deploy applications using Kubernetes and teleport-kube-agent:
- Open the
teleport/examples/chart/teleport-kube-agent/values.yamlfile that contains the application configuration in a text editor.
- Locate the
appssection in thevalues.yamlfile.
# Details of at least one app to be proxied. Example:
# apps:
# - name: grafana
# uri: http://localhost:3000
apps: []
- Add a
rewrite.headerssection similar to the followinggrafanaexample:
apps:
- name: grafana
uri: http://localhost:3000
public_addr: grafana.teleport.example.com
rewrite:
headers:
- "Origin: https://grafana.teleport.example.com" # Teleport application subdomain prepended with "https://"
- "Host: grafana.teleport.example.com" # Teleport application subdomain itself
Solution 3: Dynamic app configuration
To fix CSRF or CORS issues if you deploy applications with dynamic configuration:
- Edit your dynamic app configuration to include the
rewrite.headerssection:
kind: app
version: v3
metadata:
name: grafana
labels:
env: dev
spec:
uri: http://localhost:3000
public_addr: grafana.teleport.example.com
rewrite:
headers:
- name: "Origin"
value: "https://grafana.teleport.example.com" # Teleport application subdomain prepended with "https://"
- name: "Host"
value: "grafana.teleport.example.com" # Teleport application subdomain itself
Solution 4: Kubernetes app autodiscovery
To fix CSRF or CORS issues if you deploy applications using Kubernetes autodiscovery:
- Edit your Kubernetes
Serviceconfiguration to include therewrite.headerssection:
apiVersion: v1
kind: Service
metadata:
annotations:
teleport.dev/app-rewrite: |
headers:
- name: "Origin"
value: "https://grafana.teleport.example.com" # Teleport application subdomain prepended with "https://"
- name: "Host"
value: "grafana.teleport.example.com" # Teleport application subdomain itself
Untrusted certificate errors
By default, the certificates presented by the Teleport Proxy Service must be trusted and issued by a recognized certificate authority.
Symptom
If you have created self-signed certificates or use certificates signed by an unrecognized certificate authority, you might see an error similar to the following:
ERROR: "unable to verify HTTPS certificate chain in : \x1b[31mERROR: \x1b[0mWARNING:"
The proxy you are connecting to has presented a certificate signed by a
unknown authority. This is most likely due to either being presented
with a self-signed certificate or the certificate was truly signed by an
authority not known to the client.
Solution
If you have properly created a root certificate authority and a self-signed
certificate, you can use the --insecure command-line option to allow clients
to accept the certificate. For example, you can start Teleport with a self-signed
certificate by running a command similar to the following:
sudo teleport start --config=/etc/teleport.yaml --insecure
If you have your own certificate authority that you would like to use to
validate the certificate chain presented by the Teleport Proxy Service, you can
manually set the SSL_CERT_FILE or SSL_CERT_DIR environment variable on the
command line. For example:
sudo SSL_CERT_FILE="path/to/rootCA-pem" teleport start --config=/etc/teleport.yaml
You should specify the SSL_CERT_FILE and SSL_CERT_DIR environment variables as command-line
options because sudo doesn't inherit environment variables by default.
Request headers too large
By default, Teleport embeds the user's Teleport roles and traits in the JWT that is issued for applications. If your Teleport user has a large number of roles or traits, this can cause the JWT to become too large which will result in a failed request.
Symptom
When attempting to connect to an HTTP app behind Teleport, you see an error that states request header fields too large.
Solution
If the application that you're protecting with Teleport does not need to know about a user's Teleport roles or traits, you can configure Teleport to omit this information from the JWT. This will result in a smaller JWT that is less likely to exceed the limit.
This configuration is available under the jwt_claims property of the
application's rewrite configuration. See
Web Application Access
for details.
Login certificate is refused for an application
Clients can call some applications with the certificate that tsh login or a
Machine & Workload Identity identity output issues. See
Login certificates.
Symptom
A request made with a login certificate fails with 403 Forbidden and one of
the following messages:
This application requires a certificate for the application, such as one from `tsh app login`.
This application requires per-session MFA, which needs a certificate for the application.
Solution
The application can't be reached with a login certificate, either because of
its type or because your role requires per-session MFA for it. Retrieve a
certificate for the application with tsh apps login, or use the
application or application-tunnel service of tbot.
Login certificate is denied access to an application
Symptom
A request made with a login certificate fails with 403 Forbidden, the body
Forbidden and the header X-Teleport-App-Error-Code: access-denied.
Solution
Teleport found no application at the address that your roles allow you to access. Check the following:
- The address is the application's public address, as
tsh apps lsshows it. - Your roles allow access to the application.
- Your user isn't locked.
- The application isn't in a leaf cluster. For a leaf cluster application,
retrieve a certificate for the application with
tsh apps login.
No Application Service accepts a login certificate
Symptom
A request made with a login certificate fails with 503 Service Unavailable
and the message:
No Application Service instance can currently serve this application without a certificate for the application. Retry, or contact your Teleport administrator.
Solution
No Teleport Application Service instance that supports login certificates and
serves the application can be reached. If the instances that serve the
application are older than the Teleport Proxy Service, upgrade them to a
supported version. Otherwise, check that they are running and connected to the cluster.
Until then, use a certificate for the application from tsh apps login.
Misdirected request errors
Symptom
A client using a login certificate gets 421 Misdirected Request with the
message:
This connection serves another host. Open a new connection to the host this request names.
Solution
A connection made with a login certificate serves only the application whose address the client connected to. The error means that the client reused the connection for a request to another application. Configure the client to open a separate connection for each application.