Me : how to configure a Plesk server to allow CORS access by specifying the headers ” Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Headers: Content-Type ” ?
ChatGPT-4o : To configure a Plesk server to allow CORS (Cross-Origin Resource Sharing) by specifying headers like:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
you need to modify the web server configuration. Depending on whether you’re using Apache or Nginx, here are the steps:
✅ For Apache (common in Plesk)
Option 1: Modify .htaccess (for individual sites)
- Connect via FTP or File Manager in Plesk.
- Edit or create a
.htaccessfile in the root of your domain (e.g.,/httpdocs). - Add:
<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type"
</IfModule>
⚠️ Make sure the
mod_headersmodule is enabled on Apache.
Option 2: Use Apache directives in Plesk
- Go to Plesk > Domains > [Your Domain] > Apache & nginx Settings.
- Under Additional Apache directives, add:
<Directory />
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type"
</Directory>
- Click OK or Apply Changes.
✅ For Nginx (if used as a proxy or standalone)
- Go to Plesk > Domains > [Your Domain] > Apache & nginx Settings.
- In the Additional Nginx directives section, add:
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Content-Type' always;
- Click OK or Apply Changes.
🔁 Restart the Web Server (if needed)
If changes don’t take effect immediately, go to:
- Tools & Settings > Services Management
- Restart Apache or Nginx as needed.
✅ Test CORS Headers
Use tools like:
curl -I -X OPTIONS https://admin.ki-leierbud.lu/
You should see your CORS headers in the response.
I enabled CORS access by changing the .htaccess file.