Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server {
- # Port yang didengarkan di dalam container
- listen 80;
- server_name localhost;
- # Root direktori (harus sama dengan yang di-mount di YAML)
- root /var/www/html;
- # Konfigurasi Log (diarahkan ke folder yang sudah kita mount)
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
- # Karakter set
- charset utf-8;
- # Penanganan URL (Penting untuk framework seperti Laravel/Slim)
- location / {
- # File utama yang dicari Nginx
- index index.php index.html index.htm;
- error_page 405 =200 $uri;
- try_files $uri $uri/ /index.php?$query_string;
- }
- # Penanganan File PHP
- location ~ \.php$ {
- # Pastikan PHP-FPM berjalan di port 9000 (standard image php-fpm)
- fastcgi_pass 127.0.0.1:9000;
- # Ganti 127.0.0.1 dengan nama service PHP di docker-compose.yml
- #fastcgi_pass api_container:9000;
- fastcgi_index index.php;
- # Parameter wajib agar PHP bisa menemukan file script
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- # Optimasi Buffer
- fastcgi_intercept_errors off;
- fastcgi_buffer_size 16k;
- fastcgi_buffers 4 16k;
- }
- # Larang akses ke file .htaccess atau .git
- location ~ /\.ht {
- deny all;
- }
- # Optimasi untuk file statis (Gambar, CSS, JS)
- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
- expires max;
- log_not_found off;
- access_log off;
- }
- }
Add Comment
Please, Sign In to add comment