使用nginx做为静态服务器--监听两个域名配置

时间:2023-03-10 00:08:20
使用nginx做为静态服务器--监听两个域名配置
  1. #user  nobody;
  2. worker_processes  1;
  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;
  6. #pid        logs/nginx.pid;
  7. events {
  8. worker_connections  1024;
  9. }
  10. http {
  11. include       mime.types;
  12. default_type  application/octet-stream;
  13. #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  14. #                  '$status $body_bytes_sent "$http_referer" '
  15. #                  '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log  logs/access.log  main;
  17. sendfile        on;
  18. #tcp_nopush     on;
  19. #keepalive_timeout  0;
  20. keepalive_timeout  65;
  21. #gzip  on;
  22. server {
  23. listen       80;
  24. # 第一个域名
  25. server_name  shang.henushang.com;
  26. #charset koi8-r;
  27. #access_log  logs/host.access.log  main;
  28. location / {
  29. root   html;
  30. index  index.html index.htm;
  31. }
  32. #error_page  404              /404.html;
  33. # redirect server error pages to the static page /50x.html
  34. #
  35. error_page   500 502 503 504  /50x.html;
  36. location = /50x.html {
  37. root   html;
  38. }
  39. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  40. #
  41. #location ~ \.php$ {
  42. #    proxy_pass   http://127.0.0.1;
  43. #}
  44. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  45. #
  46. #location ~ \.php$ {
  47. #    root           html;
  48. #    fastcgi_pass   127.0.0.1:9000;
  49. #    fastcgi_index  index.php;
  50. #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  51. #    include        fastcgi_params;
  52. #}
  53. # deny access to .htaccess files, if Apache's document root
  54. # concurs with nginx's one
  55. #
  56. #location ~ /\.ht {
  57. #    deny  all;
  58. #}
  59. }
  60. server {
  61. listen       80;
  62. #第二个域名
  63. server_name  cui.henushang.com;
  64. #charset koi8-r;
  65. #access_log  logs/host.access.log  main;
  66. location / {
  67. root   html;
  68. # 设置第二个域名默认访问500错误页面以作区分
  69. index  50x.html;
  70. }
  71. #error_page  404              /404.html;
  72. # redirect server error pages to the static page /50x.html
  73. #
  74. error_page   500 502 503 504  /50x.html;
  75. location = /50x.html {
  76. root   html;
  77. }
  78. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  79. #
  80. #location ~ \.php$ {
  81. #    proxy_pass   http://127.0.0.1;
  82. #}
  83. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  84. #
  85. #location ~ \.php$ {
  86. #    root           html;
  87. #    fastcgi_pass   127.0.0.1:9000;
  88. #    fastcgi_index  index.php;
  89. #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  90. #    include        fastcgi_params;
  91. #}
  92. # deny access to .htaccess files, if Apache's document root
  93. # concurs with nginx's one
  94. #
  95. #location ~ /\.ht {
  96. #    deny  all;
  97. #}
  98. }
  99. # another virtual host using mix of IP-, name-, and port-based configuration
  100. #
  101. #server {
  102. #    listen       8000;
  103. #    listen       somename:8080;
  104. #    server_name  somename  alias  another.alias;
  105. #    location / {
  106. #        root   html;
  107. #        index  index.html index.htm;
  108. #    }
  109. #}
  110. # HTTPS server
  111. #
  112. #server {
  113. #    listen       443 ssl;
  114. #    server_name  localhost;
  115. #    ssl_certificate      cert.pem;
  116. #    ssl_certificate_key  cert.key;
  117. #    ssl_session_cache    shared:SSL:1m;
  118. #    ssl_session_timeout  5m;
  119. #    ssl_ciphers  HIGH:!aNULL:!MD5;
  120. #    ssl_prefer_server_ciphers  on;
  121. #    location / {
  122. #        root   html;
  123. #        index  index.html index.htm;
  124. #    }
  125. #}
  126. }