Added nginx as proxy server for better file serving
This commit is contained in:
parent
4d1c7702f4
commit
bddc3d97a6
5 changed files with 51 additions and 5 deletions
|
@ -13,7 +13,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final usernameController = useTextEditingController(text: 'testuser@email.com');
|
||||
final passwordController = useTextEditingController(text: 'password');
|
||||
final serverEndpointController = useTextEditingController(text: 'http://192.168.1.103:3000');
|
||||
final serverEndpointController = useTextEditingController(text: 'http://192.168.1.103:2283');
|
||||
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
node_modules/
|
||||
upload/
|
||||
dist/
|
||||
dist/
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ services:
|
|||
target: development
|
||||
dockerfile: ./Dockerfile-minimal
|
||||
command: yarn start:dev
|
||||
ports:
|
||||
- "3000:3000"
|
||||
# ports:
|
||||
# - "3000:3000"
|
||||
expose:
|
||||
- 3000
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
- userdata:/usr/src/app/upload
|
||||
|
@ -47,6 +49,21 @@ services:
|
|||
networks:
|
||||
- immich_network
|
||||
|
||||
nginx:
|
||||
container_name: proxy_nginx
|
||||
image: nginx:latest
|
||||
volumes:
|
||||
- ./settings/nginx-conf:/etc/nginx/conf.d
|
||||
ports:
|
||||
- 2283:80
|
||||
- 2284:443
|
||||
logging:
|
||||
driver: none
|
||||
networks:
|
||||
- immich_network
|
||||
depends_on:
|
||||
- server
|
||||
|
||||
networks:
|
||||
immich_network:
|
||||
volumes:
|
||||
|
|
18
server/settings/nginx-conf/nginx.conf
Normal file
18
server/settings/nginx-conf/nginx.conf
Normal file
|
@ -0,0 +1,18 @@
|
|||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
proxy_buffering off;
|
||||
proxy_buffer_size 16k;
|
||||
proxy_busy_buffers_size 24k;
|
||||
proxy_buffers 64 4k;
|
||||
proxy_force_ranges on;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_pass http://immich_server:3000;
|
||||
}
|
||||
}
|
|
@ -87,7 +87,6 @@ export class AssetController {
|
|||
return new StreamableFile(file);
|
||||
} else if (asset.type == AssetType.VIDEO) {
|
||||
// Handle Handling Video
|
||||
|
||||
const { size } = await fileInfo(asset.originalPath);
|
||||
const range = headers.range;
|
||||
|
||||
|
@ -108,6 +107,7 @@ export class AssetController {
|
|||
|
||||
// Handle unavailable range request
|
||||
if (start >= size || end >= size) {
|
||||
console.error('Bad Request');
|
||||
// Return the 416 Range Not Satisfiable.
|
||||
res.status(416).set({
|
||||
'Content-Range': `bytes */${size}`,
|
||||
|
@ -117,6 +117,8 @@ export class AssetController {
|
|||
}
|
||||
|
||||
/** Sending Partial Content With HTTP Code 206 */
|
||||
console.log('Sendinf file with type ', asset.mimeType);
|
||||
|
||||
res.status(206).set({
|
||||
'Content-Range': `bytes ${start}-${end}/${size}`,
|
||||
'Accept-Ranges': 'bytes',
|
||||
|
@ -127,8 +129,16 @@ export class AssetController {
|
|||
const videoStream = createReadStream(asset.originalPath, { start: start, end: end });
|
||||
|
||||
return new StreamableFile(videoStream);
|
||||
} else {
|
||||
res.set({
|
||||
'Content-Type': asset.mimeType,
|
||||
});
|
||||
|
||||
return new StreamableFile(createReadStream(asset.originalPath));
|
||||
}
|
||||
}
|
||||
|
||||
console.log('SHOULD NOT BE HERE');
|
||||
}
|
||||
|
||||
@Get('/all')
|
||||
|
|
Loading…
Add table
Reference in a new issue