litespeedtech / litespeedtech/openlitespeed
The environment variable is set incorrectly
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 233
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 5
Description
Hi
I want to control `Access-Control-Allow-Origin` header for multiple domains.
To do this, I make these settings:
1. Create Virtual host `front`
2. Create a static context with `/` URI
3. Set `Rewrite Rules` to :
```
RewriteCond %{HTTP:Origin} ^https?://(www\.)?(.*?example\.com3|.*?example\.com4)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [E=AccessControlAllowOrigin:%{HTTP:Origin}]
```
4. Set `Header Operations` to :
```
add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e
set service-worker-allowed /
```
5. Map Virtual host `front` to a 443 Listener

# What is happening?
In sometimes , `lsws` set incorrect `AccessControlAllowOrigin` value in response.
This mostly happens for font file requests.
## Example
Request headers :
```
GET /googleIcon/fonts/outlined2.woff2 HTTP/2
Host: example.com
User-Agent: Mozilla/5.0 (****) Gecko/20100101 Firefox/133.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: identity
Origin: https://sub1.example.com3 <<<<<<<<<<< Problem
Connection: keep-alive
Referer: https://example.com/components/googleIcon/outlined.min.css?kplhp
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
```
Response headers :
```
HTTP/2 200
cache-control: public, max-age=604800
expires: Fri, 17 Jan 2025 22:01:32 GMT
etag: "406e8-678054de-cd070;;;"
last-modified: Thu, 09 Jan 2025 22:59:42 GMT
content-type: font/woff2
content-length: 263912
accept-ranges: bytes
date: Fri, 10 Jan 2025 22:01:32 GMT
server: LiteSpeed
access-control-allow-origin: https://sub2.example.com3 <<<<<<<<<<< Problem
service-worker-allowed: /
alt-svc: h3=":443"; ma=2592000, h3-29=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="43,46"
X-Firefox-Spdy: h2
```
`OpenLiteSpeed version : 1.8.2`
Contributor guide
No contributing guide indexed for this repository
Research direction
No source files or tests are named. Reproduce the issue on OpenLiteSpeed 1.8.2 with the supplied rewrite and header operations, focusing on repeated font-file requests with different Origin values; done means Access-Control-Allow-Origin matches the request's Origin consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100