GWibisono

def.conf

Apr 18th, 2026
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. server {
  2.     # Port yang didengarkan di dalam container
  3.    listen 80;
  4.     server_name localhost;
  5.  
  6.     # Root direktori (harus sama dengan yang di-mount di YAML)
  7.    root /var/www/html;
  8.    
  9.  
  10.     # Konfigurasi Log (diarahkan ke folder yang sudah kita mount)
  11.    access_log /var/log/nginx/access.log;
  12.     error_log  /var/log/nginx/error.log;
  13.  
  14.     # Karakter set
  15.    charset utf-8;
  16.  
  17.     # Penanganan URL (Penting untuk framework seperti Laravel/Slim)
  18.    location / {
  19.     # File utama yang dicari Nginx
  20.         index index.php index.html index.htm;
  21.        
  22.         error_page 405 =200 $uri;
  23.         try_files $uri $uri/ /index.php?$query_string;
  24.     }
  25.  
  26.     # Penanganan File PHP
  27.    location ~ \.php$ {
  28.         # Pastikan PHP-FPM berjalan di port 9000 (standard image php-fpm)
  29.        fastcgi_pass   127.0.0.1:9000;
  30.        
  31.     # Ganti 127.0.0.1 dengan nama service PHP di docker-compose.yml
  32.         #fastcgi_pass  api_container:9000;
  33.        fastcgi_index  index.php;
  34.        
  35.         # Parameter wajib agar PHP bisa menemukan file script
  36.        include        fastcgi_params;
  37.         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  38.        
  39.         # Optimasi Buffer
  40.        fastcgi_intercept_errors off;
  41.         fastcgi_buffer_size 16k;
  42.         fastcgi_buffers 4 16k;
  43.     }
  44.  
  45.  
  46.  
  47.     # Larang akses ke file .htaccess atau .git
  48.    location ~ /\.ht {
  49.         deny all;
  50.     }
  51.  
  52.     # Optimasi untuk file statis (Gambar, CSS, JS)
  53.    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
  54.         expires max;
  55.         log_not_found off;
  56.         access_log off;
  57.     }
  58. }
Add Comment
Please, Sign In to add comment